3

I have been having this problem for the past two years.

I have a .jar file downloaded from the internet. It's supposed to be a rubik's cube timer.

When I double click on this .jar file, nothing happens. If I set .jar files to open with java.exe it opens a command window for a split second, and says:

Error: Could not find or load main class C:User\Dominic\Desktop\PrismaPuzzleTimer0.6.jar

If I set .jar files to open with javaw.exe, my cursor becomes that busy icon for a split second and then nothing will happen.

I have no idea what to do.

My computer is running Windows 7 64 bit. My java is version 7 update 25.

Thanks!

Dominic Ling
  • 33
  • 1
  • 1
  • 3

2 Answers2

3
  1. open a command line prompt (in the Start menu type: cmd)
  2. cd to where your jar is: cd \User\Dominic\Desktop
  3. java -jar PrismaPuzzleTimer0.6.jar
Magnus
  • 10,736
  • 5
  • 44
  • 57
  • If i remember correctly, Windows, in their infinite wisdom, allows the user to change directories with the `dir` command, rather than `cd`. – nook Jul 02 '13 at 20:24
  • Oh yeah, that rings a bell. I guess they enhanced it cuz cd worked in my Win 7 VM – Magnus Jul 02 '13 at 20:27
  • @publ1c_stat1c `cd` has definitely been supported (as a short form of `chdir`) as far back as MS-DOS. – Charles Duffy Jul 02 '13 at 20:30
  • I get this error 'java' is not recognized as an internal or external command, operable program or batch file.' – Dominic Ling Jul 02 '13 at 20:33
  • @CharlesDuffy Ahh my mistake. The 2008 server I had last year at work only let me `dir`, so I just assumed. – nook Jul 02 '13 at 20:33
  • 1
    @publ1c_stat1c: that's nonsense –  Jul 02 '13 at 20:38
1

Assuming the Manifest is properly created, you should be able to run any jar from the windows command line using something along the lines of java -jar helloworld.jar.

However, in order to double click and run it, take these steps, taken from here.

  • Open the Windows Explorer, from the Tools select 'Folder Options...'
  • Click the File Types tab, scroll down and select JAR File type.
  • Press the Advanced button.
  • In the Edit File Type dialog box, select open in Actions box and click Edit...
  • Press the Browse button and navigate to the location the Java interpreter javaw.exe.
  • In the Application used to perform action field, needs to display something similar to C:\Program Files\Java\j2re1.4.2_04\bin\javaw.exe" -jar "%1" % (Note: the part starting with 'javaw' must be exactly like that; the other part of the path name can vary depending on which version of Java you're using) then press the OK buttons until all the dialogs are closed.

You also need to make java is one of your environment variables on your path. To fix:

  1. Right-Click My Computer and select Properties
  2. Then Click The Advanced Tab
  3. Then Click Environment Variables
  4. Select Path In The Bottom Box and Click Edit
  5. Find Where You installed Java (E.g "C:\Program Files\Java\bin) Its different on each computer
  6. Make Sure to add a semicolon after the word bin in the path to seperate it from the other important paths
  7. If this doesnt work then you may have to reinstall Java and Try Again Source(s): http://www.java.com/en/download/help/path.xml

Setting Path on Windows For Windows XP:

  1. Start -> Control Panel -> System -> Advanced
  2. Click on Environment Variables, under System Variables, find PATH, and click on it.
  3. In the Edit windows, modify PATH by adding the location of the class to the value for PATH. If you do not have the item PATH, you may select to add a new variable and add PATH as the name and the location of the class as the value.
  4. Close the window.
  5. Reopen Command prompt window, and run your java code.

Taken from here.

Community
  • 1
  • 1
nook
  • 2,378
  • 5
  • 34
  • 54
  • I get this error 'java' is not recognized as an internal or external command, operable program or batch file.' when I try to open it from a command line. I'll try your other suggestion now. – Dominic Ling Jul 02 '13 at 20:35
  • I LOVE YOU YOU FIXED IT!!! Thank you so much. the end of my path was not javaw.exe" -jar "%1" % and that was the root of my problems. – Dominic Ling Jul 02 '13 at 20:39