Results 1 to 15 of 15
- 01-19-2012, 10:27 PM #1
Member
- Join Date
- Jan 2012
- Posts
- 13
- Rep Power
- 0
Error when double-clicking a jar file
Alright, so I had Eclipse generate a jar file for my mini-game, but when I double click it, it returns
On the other hand, when I run it from the command line, it runs perfectly fine. There is a Manifest file with the correct main class put in it, so that's ruled out as a possibility.Java Code:Could not find main class: Main. Program will exit.
Any Ideas?
- 01-19-2012, 10:42 PM #2
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,547
- Rep Power
- 11
Re: Error when double-clicking a jar file
If the jar's manifest correctly identifies a jar entry as the entry point to your program then it's the error message that's ruled out as a possibility.There is a Manifest file with the correct main class put in it, so that's ruled out as a possibility.
- 01-19-2012, 10:50 PM #3
Member
- Join Date
- Jan 2012
- Posts
- 13
- Rep Power
- 0
Re: Error when double-clicking a jar file
To clarify, I used
and it runs perfectly, but double-clicking doesn'tJava Code:java -jar Game.jar
- 01-19-2012, 11:06 PM #4
Member
- Join Date
- Jan 2012
- Posts
- 13
- Rep Power
- 0
Re: Error when double-clicking a jar file
Okay, while going through the Similar threads, I got that I needed to do
in the command prompt, but after trying that, it tells me "Error: unable to access jarfile %1"Java Code:"C:\Program Files\Java\jdk1.6.0\bin\javaw.exe" -jar "%1" %*
- 01-19-2012, 11:06 PM #5
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,547
- Rep Power
- 11
Re: Error when double-clicking a jar file
Where did you see the error message when you double clicked the jar file?
And, yes, what is the contents of its manifest and the location and contents of the class it specifies as the entry point?
- 01-19-2012, 11:11 PM #6
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,547
- Rep Power
- 11
Re: Error when double-clicking a jar file
What you posted in #4 doesn't look like what you'd type at the command prompt (and I'm confused: I thought you said it was already running fine from the command line.)
Rather it looks like an action you would associate jar files with in WindowsExplorer. On XP you get at these from "Tools->Folder Options->File Types".
- 01-19-2012, 11:18 PM #7
Member
- Join Date
- Jan 2012
- Posts
- 13
- Rep Power
- 0
Re: Error when double-clicking a jar file
Yeah, it runs fine from the cmd, that was just one of the answers in the similar threads.
The message when I double clicked the jar file popped up in a Java Virtual Machine Launcher thing.
The contents of the Manifest are
And the entry point is Main.classJava Code:Manifest-Version: 1.0 Class-Path: . Main-Class: Main
- 01-20-2012, 12:29 AM #8
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,547
- Rep Power
- 11
Re: Error when double-clicking a jar file
That's strange. I don't get any launcher on this machine (XP/JRE7). The default behaviour if it can't find or load the main class is basically to do nothing.The message when I double clicked the jar file popped up in a Java Virtual Machine Launcher thing.
Did you change the action associated with opening jar files as suggested in #4. That's the default for Windows. (Of course you have to set the correct path to javaw.exe for however you have installed.)
- 01-20-2012, 02:36 AM #9
Re: Error when double-clicking a jar file
You have determined that the jar file contents are ok by being able to execute it from the command prompt with the command :
java -jar Game.jar
as posted in post#4.
So the problem must be with what the OS is using as a commandline when you double click on the jar file.
- 01-20-2012, 01:00 PM #10
Member
- Join Date
- Jan 2012
- Posts
- 13
- Rep Power
- 0
- 01-20-2012, 01:05 PM #11
Re: Error when double-clicking a jar file
What version of Windows are you using? The change is easier on XP (see post #6) than on Windows7 where you will have to use the regedit program.
- 01-20-2012, 01:14 PM #12
Member
- Join Date
- Jan 2012
- Posts
- 13
- Rep Power
- 0
Re: Error when double-clicking a jar file
Windows 7
- 01-20-2012, 01:21 PM #13
Re: Error when double-clicking a jar file
I've used the regedit program to fix the commandline associated with a file extension. It allows you to edit and change the registry. If you mess up the registry, you can hurt the OS.
Ask Google about how to use regedit and see what tutorials are available.
- 01-20-2012, 01:27 PM #14
Member
- Join Date
- Jan 2012
- Posts
- 13
- Rep Power
- 0
Re: Error when double-clicking a jar file
Alright, Thanks
- 01-20-2012, 04:09 PM #15
Re: Error when double-clicking a jar file
There are various third party tools for fixing file associations in Win7. This one's free: Types
Disclaimer: I haven't tested any of said tools nor researched reviews.
dbWhy do they call it rush hour when nothing moves? - Robin Williams
Similar Threads
-
whats the difference between opening a file by double clicking it or with java?
By dhazwa in forum New To JavaReplies: 4Last Post: 08-30-2011, 05:57 AM -
Double-clicking .jar files?
By StokedOnMe in forum New To JavaReplies: 9Last Post: 04-13-2011, 04:06 AM -
Double Clicking Executable Jar File
By javawriter in forum New To JavaReplies: 7Last Post: 07-30-2010, 10:26 PM -
Double clicking executables jar files?
By cruxblack in forum New To JavaReplies: 6Last Post: 04-23-2009, 02:00 AM -
Executing JAR File by double clicking
By jasmu in forum Advanced JavaReplies: 11Last Post: 04-22-2009, 12:51 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks