简体   繁体   中英

How can I Export my Java Project in Netbeans in Executable(.exe)?

I have completed my project but unable to export in executable form. I'm using Netbeans 12.

Java applications aren't built as exe files but as jar files. The component that makes them executable is the Main-class attribute defined in the META-INF file of the jar.

In NetBeans to turn your program into an executable jar file

1)Right Click on your project->Properties->Select Run Tab on the left corner of your screen. You will see an text box saying main class, select the drop down arrow to browse through all main classes available in your project (Yes NetBeans can have multiple main classes but will run only one)

2)Optional Select the deployment tab and select compress jar to save space

3)Right Click on project->Clean and build

Then go to your projects folder on your file explorer you will see an dist(distribution) folder and there you will see your built jar file named (Project Name).jar simply double click it and the java jre will execute it

Some people have a problem running the jar file with double clicking in that case either from cmd or from an bat file type this script

set path=<path to your java.exe in your JDK/JRE bin folder>

cd (Path to where your jar file is located)

java -jar <Your Jar file>.jar

You can use Files>Export>Browse to Export in netbeans.

Thanks for everyone who wanted to help me.

Easiest Solution:

  1. Start an Ant based standard project
  2. Enable native packaging inside Properties->Build->Deployment
  3. Install Inno setup tool for Exe, Wix Toolset for Msi
  4. add bin paths of above tools as system environment variables
  5. right click on project and select package as->Exe or MSI

Note:

Netbeans 8.2 is recommended (some features are deprecated in latest version)

Screenshot

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM