{"id":1904,"date":"2022-08-30T15:20:25","date_gmt":"2022-08-30T15:20:25","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/12\/02\/after-i-convert-jar-file-to-exe-program-throws-exception-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:20:25","modified_gmt":"2022-08-30T15:20:25","slug":"after-i-convert-jar-file-to-exe-program-throws-exception-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/after-i-convert-jar-file-to-exe-program-throws-exception-collection-of-common-programming-errors\/","title":{"rendered":"After I convert JAR file to EXE, program throws exception-Collection of common programming errors"},"content":{"rendered":"<p>i have .java file. It runs perfectly. I convert it to .jar file. Then i try to convert it to .exe file using program named &#8220;exe4j&#8221;, and successfully converted. But, when i open this .exe file there is an error message:<\/p>\n<pre><code>java.util.NoSuchElementException\n     at java.util.Scanner.throwFor(Unknown Source)\n     at java.util.Scanner.next(Unknown Source)\n     at penghitung.persentase(programguru.java:27)\n     at programguru.main(programguru.java:361)\n     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)\n     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)\n     at java.lang.reflect.Method.invoke(Unknown Source)\n     at com.exe4j.runtime.LauncherEngine.launch(Unknown Source)\n     at com.exe4j.runtime.WinLauncher.main(Unknown Source)\n<\/code><\/pre>\n<p>What is the meaning? I&#8217;m confused because the .java file runs perfectly.<\/p>\n<p>Here is my code:<\/p>\n<pre><code>import java.util.*;\nimport java.io.*;\n\nclass penghitung\n{\nScanner input = new Scanner(System.in);\nint banyak, nilai, jumlah1, jumlah2, jumlah3, jumlah4, a, b, c, d, e, f, aa, bb, cc, dd, rata7;\nlong pengetahuan;\ndouble numerik, rata1, rata2, rata3, rata4, rata5, rata6;\nString pers, absen, predikat, prak, coba;\n\npublic void persentase()\n{\n    System.out.print(\"\\n           *************************************\");\n    System.out.print(\"\\n           ************START PROGRAM************\");\n    System.out.print(\"\\n           *************************************\");\n\n    System.out.print(\"\\n\\nDEFAULT : \");\n    System.out.print(\"\\n  Tugas Sekolah  : 10 %\");\n    System.out.print(\"\\n  Tugas Rumah    : 10 %\");\n    System.out.print(\"\\n  Ulangan Harian : 20 %\");\n    System.out.print(\"\\n  UTS            : 25 %\");\n    System.out.print(\"\\n  UAS            : 30 %\");\n    System.out.print(\"\\n  Keaktifan      : 5%\");\n\n    System.out.print(\"\\n\\nApakah anda ingin mengganti persentase tiap kategori? (Y\/T) : \");\n    pers = input.next();\n\n    a = 10;\n    b = 10;\n    c = 20;\n    d = 25;\n    e = 30;\n    f = 5;\n\n    if (pers.equals(\"Y\") || pers.equals(\"y\"))\n    {\n        System.out.print(\"\\n(Dalam persen)\");\n        System.out.print(\"\\n  Tugas Sekolah  : \");\n        a = Integer.parseInt(input.next());\n        System.out.print(\"  Tugas Rumah    : \");\n        b = Integer.parseInt(input.next());\n        System.out.print(\"  Ulangan Harian : \");\n        c = Integer.parseInt(input.next());\n        System.out.print(\"  UTS            : \");\n        d = Integer.parseInt(input.next());\n        System.out.print(\"  UAS            : \");\n        e = Integer.parseInt(input.next());\n        System.out.print(\"  Keaktifan      : \");\n        f = Integer.parseInt(input.next()); \n    }\n\n    System.out.print(\"\\nBanyak nilai Tugas Sekolah  : \");\n    aa = Integer.parseInt(input.next());\n    System.out.print(\"Banyak nilai Tugas Rumah    : \");\n    bb = Integer.parseInt(input.next());\n    System.out.print(\"Banyak nilai Ulangan Harian : \");\n    cc = Integer.parseInt(input.next());\n\n    System.out.print(\"\\nApakah ada nilai Praktikum? (Y\/T) : \");\n    prak = input.next();\n    if (prak.equals(\"Y\") || prak.equals(\"y\"))\n    {   System.out.print(\"Banyak nilai Praktikum : \");\n        dd = Integer.parseInt(input.next());\n    }\n}   \n\npublic void absen()\n{\n    System.out.print(\"\\n----------------------------------------------------------------\");\n    System.out.print(\"\\nNomor absen murid : \");\n    absen = input.next();\n    try \n    {\n        FileWriter out = new FileWriter(\"Data Nilai.txt\", true);\n        out.write(\"\\r\\n#################### NOMOR ABSEN MURID : \"+ absen + \"\\r\\n\");\n        out.close();\n    }\n    catch (IOException e) \n    {\n        e.printStackTrace();\n    }\n}\n\npublic void tugasSekolah()\n{\n    System.out.print(\"\\nTUGAS SEKOLAH\\n\");\n    try \n    {\n        FileWriter out = new FileWriter(\"Data Nilai.txt\", true);\n        out.write(\"\\r\\nTUGAS SEKOLAH\\r\\n\");\n\n        for (int i = 1; i  75)\n    {\n        predikat = \"TINGGI\";\n    } else if(pengetahuan == 75)\n    {\n        predikat = \"SEDANG\";\n    } else\n    {\n        predikat = \"KURANG\";\n    }\n    System.out.print(\"\\n***PREDIKAT***          : \" +predikat);\n    try \n    {\n        FileWriter out = new FileWriter(\"Data Nilai.txt\", true);\n        out.write(\"\\r\\n&gt;&gt;&gt; PREDIKAT : \" +predikat+ \"\\r\\n\");\n        out.close();\n    }\n    catch (IOException e) \n    {\n        e.printStackTrace();\n    } \n}\n\npublic void menu()\n{\n    System.out.print(\"\\n\\nTambah lagi? (Y\/T) : \");\n    coba = input.next();\n\n    if (coba.equals(\"Y\") || coba.equals(\"y\"))\n    {\n        absen();\n        tugasSekolah();\n        tugasRumah();\n        ulanganHarian();\n        uts();\n        uas();\n        keaktifan();\n        praktikum();\n        pengetahuan();\n        predikat();\n        menu();\n    }\n    else \n    {\n        System.out.print(\"\\n           **************************************\");\n        System.out.print(\"\\n           *************EXIT PROGRAM*************\");\n        System.out.print(\"\\n           **************************************\");\n    }\n}\n}\n\n\npublic class programguru\n{\npublic static void main (String args[])\n{       \n    penghitung penghitungku = new penghitung();\n\n    \/\/PERSENTASE NILAI\n    penghitungku.persentase();\n\n    \/\/NOMOR ABSEN\n    penghitungku.absen();\n\n    \/\/NILAI TUGAS SEKOLAH\n    penghitungku.tugasSekolah();\n\n    \/\/NILAI TUGAS RUMAH\n    penghitungku.tugasRumah();\n\n    \/\/NILAI ULANGAN HARIAN\n    penghitungku.ulanganHarian();\n\n    \/\/NILAI UTS\n    penghitungku.uts();\n\n    \/\/NILAI UAS\n    penghitungku.uas();\n\n    \/\/NILAI KEAKTIFAN\n    penghitungku.keaktifan();\n\n    \/\/NILAI PRAKTIKUM\n    penghitungku.praktikum();\n\n    \/\/NILAI PENGETAHUAN\n    penghitungku.pengetahuan();\n\n    \/\/PREDIKAT\n    penghitungku.predikat();\n\n    \/\/MENU TAMBAH\n    penghitungku.menu();\n}\n}\n<\/code><\/pre>\n<ol>\n<li>\n<p>Just guessing here, since there is incomplete information: the error message indicates that you have an error about where you first do an &#8220;input.next();&#8221; in addition to indicating that there is &#8220;no such element&#8221;. If you are on Windows, and you are starting this executable by double-clicking an icon in a folder, then you have to figure out where &#8220;System.in&#8221; will come from. Windows will not automatically open up a command window for you to type input; if you want that, you have to run it a different way.<\/p>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2013-12-02 21:16:58. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>i have .java file. It runs perfectly. I convert it to .jar file. Then i try to convert it to .exe file using program named &#8220;exe4j&#8221;, and successfully converted. But, when i open this .exe file there is an error message: java.util.NoSuchElementException at java.util.Scanner.throwFor(Unknown Source) at java.util.Scanner.next(Unknown Source) at penghitung.persentase(programguru.java:27) at programguru.main(programguru.java:361) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1904","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1904","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1904"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1904\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1904"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1904"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1904"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}