Hello!
I have made a java program in Netbeans IDE (version 7.1). I want to make a file that could run my project without IDE (with the help of just Java, JRE, etc)....

I had made a JAR file to try this, but when I open the file, i cant see anything

Please tell me what to do

Thanks in advance


Regards
Daksh shah

you can run each (desktop) or command line java application, by running the next command prompt command on the class file:

javac yourClass (if yourClass is the class that contains your main method, of course :) )

normally, a .jar file should work and get you able to run your app by clicking the file, but if your environment is not correctly set, it's possible that your system does not recognize the .jar as an executable file.

Edited 4 Years Ago by stultuske: just to be complete

you can run each (desktop) or command line java application, by running ... javac yourClass

Are you sure? java or javaw work better in this reality :)

Edited 4 Years Ago by JamesCherrill: n/a

Comments
damn typo :) should re-read my posts more often before pressing the button

All of this depends on the .jar file being correctly created, right?
Right now, it could be either the system isn't correctly running the .jar or the compiler didn't create it properly.

If you open the jar file using any zip utility ( a jar file is just a zip file with a different extension) you should be able to find your class file(s) and a folder called META-INF containing a file called manifest.mf If you have that then it's probably a system setup problem. If you don't have those then you haven't created your executable jar properly

Edited 4 Years Ago by JamesCherrill: n/a

He didn't tell us whether it was a GUI or CUI based application. @daksh1998, non-Graphical-User-Interface programs do not open when you double-click their JAR files on MS-Windows. You will HAVE to use the command line to open non-GUI based Java programs.

Edited 4 Years Ago by dantinkakkar: n/a

if you read my post: JamesCherrill is right with his comment:

javac MyClass.java => compile your class
java MyClass => actually running the class.

Ya, I don't deny. :)

Just tried to put it in simple terms for the asker's benifit, 'coz I faced the same issue when I was a Java learner one and a half years ago... :P
Dunno whether I was successful, though :D

Edited 4 Years Ago by dantinkakkar: n/a

@dantinkakkar, i dont noe dat it is GUI or CUI, but I know that I have coding and labels, buttons etc used.....

And one more thing, I am able to open a readymade jar program.....

i dont know what to do can anyone please simplify in detail and then tell me

you have labels and buttons, but you don't know whether it has a GUI or not, or what kind of GUI it would have if it had one?

did you write this code yourself, or just got it somewhere?
anyway. you have a GUI (which means Graphical User Interface) written in (probably) Swing.

if you are able to open a 'readymade jar program', than put your program in a jar file and run it.

it IS not a GUI, it uses one. but that is irrelevant.
a .jar file is an executable, which you can run by simply clicking it, that is, if your manifest file points to the right entry point and your configuration of your system is correct.
you can always also start up your application by command prompt/console.

are you still looking for an answer for this after a year?

yeah; actually a had made a project in java (using netbeans);
1st project has Database Incl.
2nd is simple
I want to convert both of them into simple executable (maybe JAR)
So that i can run those programs on different machines which
dont have IDE Netbeans. Or dont need any special requirement
I want to run like the other jar executable files(which install themselves)
Please give me reply on how to do it STEP BY STEP
Thanks in advance

there will always be a requirement: a supported JRE must be installed.
well, then build your netbeans project, and check your dist (from distribution ) folder. that'll contain a .jar file, which is about all you need.

Edited 3 Years Ago by stultuske

but that jar doesnt work on systems; on which other jars work but this jar doesnt work

that sentence makes no sense:
it does not work on systems on which other jars work ...
well, either there is no main method, or you didn't point right to it in your manifest.mf file.

This article has been dead for over six months. Start a new discussion instead.