Need to export clickable and executable file in eclipse. Simple exporting does not launch the program. How to get a clickable jar?
-
what exactly did u try search in google ?? – Srinath Ganesh Apr 29 '15 at 14:02
-
there are two types of jar 1) normal jar of libraries **jar** 2) another is **executable jar** – Srinath Ganesh Apr 29 '15 at 14:03
-
You should probably read this: https://docs.oracle.com/javase/tutorial/deployment/jar/basicsindex.html – Virginie Apr 29 '15 at 14:05
-
Srinath, "How to create runnable file from eclipse." Could you create and show me your result ? – Farhad Mammadli Apr 29 '15 at 14:06
-
Try this: http://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Ftasks%2Ftasks-37.htm – Ian2thedv Apr 29 '15 at 14:09
3 Answers
You should click file
, then click export
, then click java
and save it as runnable jar file
.
To run the .jar
file, open cmd or terminal, make sure you are in the right path and
type java -jar <jar-file-name>.jar
Note if you cant run it, mostly its your file path not correct

- 4,120
- 6
- 36
- 66
-
-
i got your answer, but is there any way to run it without cmd ? – Farhad Mammadli Apr 29 '15 at 14:17
-
-
You have to add an entry name `Main-Class` in MANIFEST file, or run as `java -cp
`: http://docs.oracle.com/javase/tutorial/deployment/jar/appman.html
Try to go in brief using the below link : http://www.wikihow.com/Create-an-Executable-File-from-Eclipse

- 56
- 3
-
-
-
try to run using java -jar
and tell is it throwing any exception??? – Vishrut Majmudar Apr 29 '15 at 14:16 -
-
@FarhadMammadli What do you mean, run it without cmd? Its a command line application that expects input from the command prompt itself. The question would make sense if it were for example a Swing or JavaFX application which actually opens up a graphical window. – Gimby Apr 29 '15 at 15:02
-
@gimby i am beginner in java, thanks for reply, i have to switch to the swing – Farhad Mammadli Apr 29 '15 at 15:30
-
@FarhadMammadli okay I understand, I converted that comment into an answer. – Gimby Apr 30 '15 at 14:15
The code listing represents a command prompt application; you can only make it do anything when physically run on the command prompt / shell itself, especially because it expects user input that way. The reason why turning the given program into an executable jar will result in "nothing" happening when you double click it, is because under Windows the default binding for the 'jar' filetype will be setup to run through javaw.exe - and javaw.exe is designed to not open up any command prompt.
In order to make a program be able to run without the command prompt so you only have to double click on it, you will need to get rid of the command prompt interface and instead build a proper graphical user interface, using for example JavaFX or Swing.

- 5,095
- 2
- 35
- 47