I made a desktop application with Java netbeans, it's a Jframe with some components. I built it and the .jar file created in the dist folder in the project folder. I have already the jre (Java Runtime Environment) installed on my pc. When I try to open the .jar with the jre I got nothing, Nothing appears. What can I do ?
Asked
Active
Viewed 436 times
-1
-
you sure it don't crashes on the start? – Christian 'fuzi' Orgler Apr 11 '13 at 00:18
-
1Go to the command line. Change directories to where the jar file is type `java -jar {nameOfJar}.jar` - assuming the Java is in the path – MadProgrammer Apr 11 '13 at 00:18
-
@MadProgrammer how can i do that ? please explain more – Jack Apr 11 '13 at 00:20
-
Open a command prompt, `CD` to the location of the jar file and use `java -jar {nameOfJar}.jar` to execute the Jar. If you're unfamiliar with how to use the command prompt/terminal then I suggest you need to find a better tutorial on the subject... – MadProgrammer Apr 11 '13 at 00:23
-
@MadProgrammer should I remover the { } ?? java -jar {nameOfJar}.jar or java -jar nameOfJar.jar – Jack Apr 11 '13 at 00:29
-
Yes - sorry, I don't know the name of your jar file so I added a filler – MadProgrammer Apr 11 '13 at 00:31
-
No Problem, now I tried to execute the .jar file normally (not through using CMD), there is an error message saying (A Java Exception Error) with a title Java Virtual Machine Launcher – Jack Apr 11 '13 at 00:34
-
When I try to run through CMD there's Unsupported major.minor version 52.0 – Jack Apr 11 '13 at 00:36
-
@user2266606 Read my answer below (especially the edited to add part) – Mel Nicholson Apr 11 '13 at 00:58
1 Answers
0
https://netbeans.org/kb/articles/javase-deploy.html#Exercise_1
The link above will take you to a tutorial. Jar files are not executable by default. You need to specify a starting class to make a jar file executable.
If this doesn't work, then make sure you have called setVisible(true)
on your JFrame.
Edited to add: (author added info)
When I try to run through CMD there's Unsupported major.minor version 52.0
This means your JRE version does not match your compiler version. You can confirm with the -version option, then fix your path to use Java from the same place your compiler lives.

Mel Nicholson
- 3,225
- 14
- 24
-
-
See also: http://stackoverflow.com/questions/4681090/how-to-find-where-is-jdk-installed-on-my-windows-machine – Mel Nicholson Apr 11 '13 at 15:18