Results 1 to 20 of 26
- 06-21-2010, 05:01 AM #1
Member
- Join Date
- Jun 2010
- Posts
- 29
- Rep Power
- 0
Could Not Find Main Class (again)
i did some searching around this site and on google and such and after about a month i have decided to make an account for the sole purpose of asking this question.
To be clear: I DO NOT SPEAK JAVA
The Problem: After recently updating Java to the latest version (20) I now get the following error running any .jar file. "Could Not Find The Main Class: *****/**/***.jar Program Will Exit." ** are examples.
What I have tried reinstalling java.
clearing out old versions.
What i have found and am confused with, something in the cmd with java -cp -jar ***.jar
I would like to be helped over teamviewer if at all possible. You can either leave a reply here or if it is close to the time i have posted please feel free to join me in my irc here. Rizon Web IRC (qwebirc) i am nick1 just name yourself javaforum so i know your there to help me, thanks so much in advance.Last edited by illjavathat; 06-21-2010 at 05:10 AM.
- 06-21-2010, 06:51 AM #2
Senior Member
- Join Date
- Nov 2009
- Posts
- 150
- Rep Power
- 4
do you get this with every jar?
its normal you get it with ones that don't have their manifest files set...
download beanshell and start it up, does that works?
- 06-21-2010, 06:59 AM #3
Senior Member
- Join Date
- Dec 2008
- Posts
- 526
- Rep Power
- 0
look the manifest.MF file and tell us does it contain a main class ref...
If my answer helped you. Please click my "REP" button and add a comment
Have a Good Java Coding :)
- 06-21-2010, 07:09 AM #4
Member
- Join Date
- Jun 2010
- Posts
- 29
- Rep Power
- 0
"I now get the following error running any .jar file"
and for beanshell...? i downloaded first file from this page...
BeanShell - Downloads
and yes i got could not find main class.
edit 1: here i searched for a manifest.mf file and upon running found it was deleted... http://dl.dropbox.com/u/120327/javaerror1.jpg
i should have mentioned that i do not speak java lol, as i said this is for ANY jar file but the one i am trying to use right now contains a manifest.txt file listed as this.
EDIT 2: in C:\Program Files\Java\jre6\lib\ext i had qtjava.ZIP ...? i unzipped and now have the correct files but still the wrong errors now i think changing my environment variables will do something...?Java Code:Main-Class: org.rsbot.Boot Name: org/rsbot Sealed: true Specification-Title: "RSBot" Specification-Vendor: "org.rsbot" Implementation-Title: "RSBot" Implementation-Vendor: "org.rsbot"
Edit3: was i supposed to unzip that?Last edited by illjavathat; 06-21-2010 at 07:20 AM.
- 06-21-2010, 01:04 PM #5
Can you copy and paste here the FULL contents of the console when you try to execute the java program - show command and response.
- 06-21-2010, 10:21 PM #6
Member
- Join Date
- Jun 2010
- Posts
- 29
- Rep Power
- 0
I thought i was pretty clear in my first message, however here is a screenshot of the error I get when running rsbot.jar (example 1) and IcePushClient.jar (example 2)
Previously Posted Exmaple: http://dl.dropbox.com/u/120327/javaerror1.jpg
Example 1: http://dl.dropbox.com/u/120327/javaerror2.jpg
Example 2:http://dl.dropbox.com/u/120327/javaerror3.jpg
Thanks...
- 06-21-2010, 10:26 PM #7
Sorry, the output from your java program launcher doesn't mean anything to me.
Can you open a command prompt window and run it from there and copy the contents of the screen. I need to see the command that was issued and the FULL text of the error message that comes from the java command.
- 06-22-2010, 01:47 AM #8
Member
- Join Date
- Jun 2010
- Posts
- 29
- Rep Power
- 0
Rizon Web IRC (qwebirc) anyway you can join me there (if your still on and i can talk live/ teamviewer?) thanks so much.
i am not sure what command is used to run this i am simply opening ANY .jar file...?
- 06-22-2010, 02:06 AM #9
Open a command prompt, move to the folder with the jar file and enter:i am simply opening ANY .jar file
java -jar yourjarfilenamehere.jar
- 06-22-2010, 03:05 AM #10
Member
- Join Date
- Jun 2010
- Posts
- 29
- Rep Power
- 0
well this is the wierd part because from the cmd it works (no error, no response), i knew about this but i am really looking for a fix rather than this workaround. i dont understand why the cmd method is any different than running it normally.
i can give you an example of a specific jarfile and the .bat file typically used to start it.
Play.bat
now running this batch file i would get the main class error, HOWEVER if i make a new batch file simply sayingJava Code:@ECHO OFF SET cc=javac SET cflags= SET src=src SET lib=lib SET res=resources SET out=bin SET jarout=data CALL Clean.bat 2>NUL CALL "%res%\FindJDK.bat" SET lstf=temp.txt SET imgdir=%res%\images SET manifest=%res%\Manifest.txt SET versionfile=.version FOR /F %%G IN (%versionfile%) DO SET version=%%G SET scripts=scripts SET dist=RSBot.jar SET full=1 IF "%1"=="/S" ( SET full=0 GOTO :scripts ) ECHO Compiling bot IF EXIST "%lstf%" DEL /F /Q "%lstf%" FOR /F "usebackq tokens=*" %%G IN (`DIR /B /S "%src%\*.java"`) DO CALL :append "%%G" IF EXIST "%out%" RMDIR /S /Q "%out%" > NUL MKDIR "%out%" "%cc%" %cflags% -d "%out%" "@%lstf%" 2>NUL DEL /F /Q "%lstf%" :scripts ECHO Compiling scripts ECHO. > "%scripts%\.class" DEL /F /Q "%scripts%\*.class" > NUL "%cc%" %cflags% -cp "%out%" %scripts%\*.java IF "%full%"=="0" GOTO :end ECHO Packing JAR IF EXIST "%dist%" DEL /F /Q "%dist%" IF EXIST "%lstf%" DEL /F /Q "%lstf%" COPY "%manifest%" "%lstf%" ECHO Specification-Version: "%version%" >> "%lstf%" ECHO Implementation-Version: "%version%" >> "%lstf%" IF NOT EXIST "%jarout%" MKDIR "%jarout%" jar cfm "%jarout%\%dist%" "%lstf%" -C "%out%" . %scripts%\*.class %res%\version.dat %imgdir%\*.png %res%\*.bat %res%\*.sh DEL /F /Q "%lstf%" :end ECHO Compilation successful. GOTO :eof :append SET gx=%1 SET gx=%gx:\=\\% ECHO %gx% >> %lstf% GOTO :eof
then it works... it is a hassle to do this for each jarfile and i am confused about why its happening. thanks for all the help so far and to come in advance.Java Code:start play.bat
PS if the play.bat code was unneeded then so be it, like i said i dont understand much.
- 06-22-2010, 03:40 AM #11
I run java programs all the time by having shortcuts that execute the command: java -jar filename.jari am really looking for a fix rather than this workaround.
running it normally
So I consider that the normal way to execute a jar file.
When java is installed on Windows the install process puts an entry in the registry that uses the java -jar %1 command. Then when you double click on a jar file that command is executed.
I'm very confused on what your problem is?
I do not see anywhere in the batch file you posted that it executes a jar file. The batch file creates a jar file using the jar command:
jar cfm "%jarout%\%dist%" ....
Please explain your problem and document it with a screen print if you can.
What program were you running for the screen prints you posted earlier?
- 06-22-2010, 05:28 AM #12
Member
- Join Date
- Jun 2010
- Posts
- 29
- Rep Power
- 0
so i need to edit my registry values...? was it replaced right now? can someone fix this for me over teamviewer or if someone is on atm please join the chat link is in first post.
- 06-22-2010, 09:48 AM #13
Moderator
- Join Date
- Apr 2009
- Posts
- 10,475
- Rep Power
- 16
So are you getting this because you are running thsat BAT file?
If that's the case, does it work when you simply double click on the jar file?
If that works, and the command line one works (as you say above), then java is working...and it is simply down to whatever that BAT file is doing.
- 06-22-2010, 12:44 PM #14
You shouldn't have to edit the Registry. The install process makes entries there.
What is displayed in the Type column in Windows Explorer for jar files?
On my system its: Executable Jar File.
If java wasn't installed it would say: Jar File
does it work when you simply double click on the jar file?
- 06-22-2010, 05:39 PM #15
Member
- Join Date
- Jun 2010
- Posts
- 29
- Rep Power
- 0
- 06-22-2010, 06:30 PM #16
If the column says Jar File that is the default type that Windows gives to files that it doesn't know what to do with. When java is installed it changes the type name for jar files to be Executable Jar File.
Where did you post the Full contents of this error message? I can't see it. See my post#9it gives the main class error.
It could be that you need to reinstall java. That will associate the jar file with the "java -jar %1" command and change the type to "Executable Jar File".
- 06-22-2010, 06:40 PM #17
Member
- Join Date
- Jun 2010
- Posts
- 29
- Rep Power
- 0
i have tried reinstalling java. http://dl.dropbox.com/u/120327/javaerror2.jpg is the full error.
- 06-22-2010, 06:46 PM #18
Please read post#9. I have no idea what the screen print you posted is.
What program displays the "Java Virtual Machine Launcher" window? I've never seen it.
One more idea. Do the following to get command line executed when a jar file is doubleClicked:
Open Windows Explorer
Click on Tools menu
Click on Folder Options
Select File Types tab
Scroll down in the "Registered file types:" list until you see an entry for JAR.
Select the JAR entry.
Click the Advanced button
In the Edit File Type window scroll down the list of Actions until you see the one in bold.
Select the bold one
Click the Edit button
Select, Copy and paste here what is in the "Application used to perform action:" window.
Be careful not to change anything and Cancel your way out of the open windows.Last edited by Norm; 06-22-2010 at 07:02 PM.
- 06-23-2010, 02:25 AM #19
Member
- Join Date
- Jun 2010
- Posts
- 29
- Rep Power
- 0
- 06-23-2010, 02:32 AM #20
No idea what this means. Can you explain?i could not find device types for changing to a cmd line.
What is the date on the javaw.exe file you are executing?
Did you try the steps I listed for getting the commandline from Windows Explorer?
Do a google on Java Virtual Machine Launcher
There are several forums where problems with that has been discussed
Similar Threads
-
could not find main class?
By deathnote202 in forum New To JavaReplies: 6Last Post: 05-10-2010, 08:57 PM -
Could not find main class
By Andyj in forum New To JavaReplies: 2Last Post: 10-06-2009, 12:47 AM -
Cannot find Main class in Linux OS
By msskiran in forum EclipseReplies: 0Last Post: 04-10-2009, 02:04 AM -
Could not find main class - JDK 1.6
By Syranno in forum New To JavaReplies: 1Last Post: 07-25-2008, 04:07 PM -
JVM Could not find main class
By banduskank in forum Advanced JavaReplies: 2Last Post: 06-24-2008, 08:05 AM


LinkBack URL
About LinkBacks


Bookmarks