You do that by specifying the main class of your application, any extra jar files it may require and so on in the jar's manifest file Main-Class: MyAppMain Class-Path: mylib.jar You can make your Java application runnable via a double-click by packaging it into a so called executable jar. Single distribution for all Java-enabled platformsConsĪpplication will not start on systems that do not have a JRE (properly) installedĪpplication will not work if it uses APIs absent in the default JRE Before J2SE 1.4, all you could make with JDK tools were Executable Jars What surprises newbie Java developers is that the JDK does not offer such functionality. So it comes as no surprise that the primary motivation for seeking a way to convert a Java application into an EXE file is to make its deployment and use simpler and safer for an average user, that is, a Windows user. Or, even better, enable it to be installed and uninstalled in a native manner without affecting other applications. Yes, you may put that line into a batch file and call it runme.bat, but it looks so much easier to give your program to a friend, teacher or colleague as a single file that can be run by a double-click. Java -Xmx200m -cp whatever.jar -Dsome.property MyApp Then, even if you can make sure the right version of the JRE is properly installed on enduser systems, which is quite possible in a classroom or enterprise environment, the command line required to launch your Java application can be quite long: And those who already have a JRE installed may not like the idea about installing a different version, because it may break their existing Java applications and favorite applets. This is especially true for consumer applications, such as games or multimedia. In a general case you may not expect that your end users will know what a JRE is, how to check its version, and how to download and install it. This in turn means that the author of that program has to ensure somehow that the proper version of the JRE is installed on an end user system. So a Java program needs a Java Runtime Environment (JRE) to run, which would either interpret the bytecode instructions or compile them to native code on the fly. Java compiles to platform-independent bytecode (.class files), which is not directly supported by PC hardware. Improve startup time of your Java applications. ![]() And the most frequent answer would be Simplify Java Application Deployment ![]() So the most correct way to reply to such a post would be a request for more information, namely what is the goal of conversion to EXE. Moreover, under certain conditions some of those problems may be solved without making an EXE. The truth is that there exist two completely different approaches to the creation of native executables from Java applications, addressing different sets of problems. ![]() "You can do that with third party software X and Y"."You should not, because that would kill the very purpose of Java".Should you start such a topic today, you are likely to encounter the following three types of replies: EXE file from my Java application?", "Need help converting jar to exe", "Is it possible to create a Windows executable using Java?" - these and similar questions are among the most popular topics on Java developer forums. If you are sure you need a real EXE, go straight to AOT Compilers.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |