making .exe file for java project containing sqlite

眉间皱痕 提交于 2019-12-23 03:56:11

问题


I want to create .exe file for my java project and give it to my friend. I wrote my project in eclipse and it uses sqlite. I don't know how to make a .exe file that can be run in other PCs. Can any one help? P.S:I saw this link but it is not useful for me! Create .jar of an eclipse project that uses Sqlite DB


回答1:


.exe is a creature of Windows.

To run a Java program, you typically:

  1. Create a .jar file (the "native" Java library format)

  2. Write a DOS/Windows .bat file (or, equivalently, Linux shell script) to run your Java program (using the Java .jar file)

  3. Optionally, create some easy-to-use mechanism for the end user to download the Java JRE (if it's not already installed on their PC).

Your .bat file can be as simple as this:

start javaw -jar myjarfile.jar



回答2:


Have you considered creating Runnable jar from eclipse.

In eclipse, go to File > Export > Java > Runnable Jar.

There you ll find some options and you can use what suits you. The jar created should be able to run all by itself (obviously it needs the java run time).

Try this out.




回答3:


I would recommend using a bat file. You can make a double clickable jar file, but I feel that is sometimes restrictive and not intuitive.

  1. Not many end-users know that a jar file is double clickable.
  2. You need to make sure the jar file has a main class and classpath defined. The classpath section in the jar file sometimes causes issues. Like you cannot reference a file or path on the file system. Only files or folders that can be relatively referenced from the location of the jar file.
  3. For windows users, you cannot easily make an exe file from a jar file. There are methods like using jsmooth, that will wrap your jar file into an exe file (bloating the exe file in the process).

The easiest way is to create a bat file. You can easily convert a bat file into an exe and make the exe file have an icon and everything. Link to a converter here:

http://download.cnet.com/Bat-To-Exe-Converter/3000-2069_4-10555897.html




回答4:


  1. First create an executable jar file by clicking on File menu, then export, and then select runnable jar file.
  2. Then select main class and click ok - the jar file will be created.
  3. After that use Launch4j application to create .exe. Launch4j is the best option for creating an exe file.
  4. Then use Inno Setup Creater to create an installer and it is done.


来源:https://stackoverflow.com/questions/8774546/making-exe-file-for-java-project-containing-sqlite

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!