I tried to put HelloWorld in a .jar file and running it, but it doesn't work. I created the java file and typed in the program, and then wrote in cmd:
echo Main-Class: HelloWorld >manifest.txt
jar cvfm HelloWorld.jar manifest.txt HelloWorld.class
adding: HelloWorld.class(in = 426) (out= 288)(deflated 32%)
java -jar HelloWorld.jar
Error: Could not find or load main class path\HelloWorld.jar
(echo Manifest-Version: 1.0
echo Class-Path: .
echo Main-Class: com.stackoverflow.user.blrp.HelloWorld) >manifest.txt
jar cvfm HelloWorld.jar manifest.txt com\stackoverflow\user\blrp\HelloWorld.class
adding: com/stackoverflow/user/blrp/HelloWorld.class(in = 454) (out= 312)(deflat
Thanks jbaliuka for the suggestion. I opened the registry editor (by typing regedit in cmd) and going to HKEY_CLASSES_ROOT > jarfile > shell > open > command, then opening (Default) and changing the value from
"C:\Program Files\Java\jre7\bin\javaw.exe" -jar "%1" %*
"C:\Program Files\Java\jre7\bin\java.exe" -jar "%1" %*
(I just removed the w in javaw.exe.) After that you have to right click a jar -> open with -> choose default program -> navigate to your java folder and open \jre7\bin\java.exe (or any other java.exe file in you java folder). If it doesn't work, try switching to javaw.exe, open a jar file with it, then switch back.
I don't know anything about editing the registry except that it's dangerous, so you might wanna back it up before doing this (in the top bar, File>Export).