i have created a java project in NetBeans. now i want to make an executable file out of it.that can be executed (run) in other computers that have JDK or JRE installed but don't have NetBeans or any other Java IDE installed.how can i do such thing using NetBeans???
-
@this question can be reopened as through netbeans its possible to create native jar as well as described here https://netbeans.org/kb/docs/java/native_pkg.html what is marked as duplicate is how to create an executable JAR. – Vishrant Apr 27 '18 at 22:48
3 Answers
Do you mean compile it to JAR? Netbeans does that automatically, just do clean and build
(hammer sybol) and look in the dist
subdirectory of your project. There will be the JAR with lib
folder containing the required libraries. These JAR + lib are enough to run the application.
Maby you unchecked an option:
Project Properties -> Build -> Packaging -> Build JAR after compiling
(but this is enabled by default)

- 3,719
- 14
- 40
- 62
-
1i found the dist folder and in that folder there are just one jar file and one readme text but jar file doesn't work.and there is no lib folder.i am guessing that it is the problem. and also i opened the jar with winrar and there weren't anything in it but classess of the project and one "MANIFEST.MF" .what should i do? – Gandalf Aug 06 '13 at 19:52
-
thats all right, the jar file is the executeable file, you can either double click it, or use cmd **java -jar [JARFILENAME.JAR]** Lib folder will only created when needed, if you dont uses external libs you wont need this folder. Found a short video which shows what excatly to and how it looks like: http://www.youtube.com/watch?v=LF5cLVivV_Y – Dennis Kriechel Aug 06 '13 at 19:54
-
And here with Pictures: http://www.javaquery.com/2011/12/how-to-create-jar-file-in-netbeans.html – Dennis Kriechel Aug 06 '13 at 20:04
-
1thank u it was really helpful. but i double click on jar file as i said before and it doesn't work .why do you think it doesn't work?? i haven't used GUI do u think that is why. – Gandalf Aug 06 '13 at 20:07
-
Ah if you have no gui than you wont see the program running, but if there is no error message its running. You need to open cmd and switch to your dist directory using **java -jar YOURJARFILE** than you will see the output in cmd – Dennis Kriechel Aug 07 '13 at 04:42
You have to build your project. Just click on the hammer in the toolbar. After that there should be a folder in your project called "dist".
In it is the *.jar File, which you can deploy to anybody who has Java installed.

- 61
- 3
you mean executable jar file. which can be executed using $java -jar myJar.jar . So you need to change manifest file inside jar. Second if you want a mouse double click execution then for Linux create .sh and for windows create .bat file containing the above specified $java -jar .
JVM installation is required to do so on whichever machine you want to execute.

- 1
- 1

- 1,161
- 9
- 17