VaM999
VaM999

Reputation: 471

Executable jar file is not responding and not running

I wanted to convert .java file to executable jar file,i did so in the command prompt. But everytime i double click (open) it nothing happens.

jar cf Calculate.jar Calculator.java

This is what i typed in the cmd. How to get an executable file? I use windows

Upvotes: 1

Views: 743

Answers (1)

uraimo
uraimo

Reputation: 19821

That's not how it works, that way you are creating a jar archive with that .java file in it.

If you want to create the jar manually (if you want to do it one time, instead of using a build tool like ant or maven, it could have some educational value), you have to compile your .java file to a .class with javac, add it to the jar and then modify the META-INF/MANIFEST.MF manifest file to specify Calculator as value for the Main-Class attribute.

See this old guide from Sun.

Upvotes: 1

Related Questions