0

I can run my project through netbeans but after I make a jar file and double click it I get the error cannot find Java runtime environment? I am on Windows.

Nathan Campos
  • 28,769
  • 59
  • 194
  • 300
anon
  • 697
  • 3
  • 14
  • 19
  • 2
    How do you have the JRE installed? When you open a Command Prompt, what happens when you run "java" ? – Suppressingfire Nov 12 '09 at 19:49
  • I added the "windows" tag, since the question is not really about java, but about running java on windows. It might be relevant which kind of windows? – Rasmus Kaj Nov 12 '09 at 20:03

7 Answers7

1

Make sure you have JRE installed. Open the console and type java -version

Bozho
  • 588,226
  • 146
  • 1,060
  • 1,140
1

You should download a Java runtime environment.

adhanlon
  • 6,407
  • 13
  • 43
  • 41
1

You don't have a file associate created. Right click on the .jar file in Internet Explorer, select Open With, and navigate to your JRE. Select the java.exe executable, and make sure the command-line argument has ' -jar ' present.

The .jar file will be passed as the first argument to the JVM.

Chris K
  • 11,996
  • 7
  • 37
  • 65
1

You might try, as Chris said, making sure the JRE executable is part of your PATH environment variable. Check out "4. Update the PATH variable (Optional)" from this guide.

poundifdef
  • 18,726
  • 23
  • 95
  • 134
0

Make sure the JRE bin dir is in your PATH env variable.

Chris Lacasse
  • 1,502
  • 10
  • 10
0

It's all about the Manifest - http://java.sun.com/docs/books/tutorial/deployment/jar/manifestindex.html

0

In Netbeans run the project. It will ask you what class to run (you will see a list of all the classes with a "public static void main(String[])" method). Once you do that the next time you build the class netbeans will show you how to run it (with the -jar witch). Now you should be able to double click on it.

TofuBeer
  • 60,850
  • 18
  • 118
  • 163