Page 1 of 2 12 LastLast
Results 1 to 20 of 26
  1. #1
    illjavathat is offline Member
    Join Date
    Jun 2010
    Posts
    29
    Rep Power
    0

    Default 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.

  2. #2
    dinosoep is offline Senior Member
    Join Date
    Nov 2009
    Posts
    150
    Rep Power
    5

    Default

    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?

  3. #3
    Webuser is offline Senior Member
    Join Date
    Dec 2008
    Posts
    526
    Rep Power
    0

    Default

    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 :)

  4. #4
    illjavathat is offline Member
    Join Date
    Jun 2010
    Posts
    29
    Rep Power
    0

    Default

    Quote Originally Posted by dinosoep View Post
    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?
    "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.

    Quote Originally Posted by Webuser View Post
    look the manifest.MF file and tell us does it contain a main class ref...
    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.

    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"
    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...?
    Edit3: was i supposed to unzip that?
    Last edited by illjavathat; 06-21-2010 at 07:20 AM.

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,331
    Rep Power
    25

    Default

    Can you copy and paste here the FULL contents of the console when you try to execute the java program - show command and response.

  6. #6
    illjavathat is offline Member
    Join Date
    Jun 2010
    Posts
    29
    Rep Power
    0

    Default

    Quote Originally Posted by Norm View Post
    Can you copy and paste here the FULL contents of the console when you try to execute the java program - show command and response.
    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...

  7. #7
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,331
    Rep Power
    25

    Default

    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.

  8. #8
    illjavathat is offline Member
    Join Date
    Jun 2010
    Posts
    29
    Rep Power
    0

    Default

    Quote Originally Posted by Norm View Post
    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.
    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...?

  9. #9
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,331
    Rep Power
    25

    Default

    i am simply opening ANY .jar file
    Open a command prompt, move to the folder with the jar file and enter:
    java -jar yourjarfilenamehere.jar

  10. #10
    illjavathat is offline Member
    Join Date
    Jun 2010
    Posts
    29
    Rep Power
    0

    Default

    Quote Originally Posted by Norm View Post
    Open a command prompt, move to the folder with the jar file and enter:
    java -jar yourjarfilenamehere.jar
    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
    Java 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
    now running this batch file i would get the main class error, HOWEVER if i make a new batch file simply saying
    Java Code:
    start play.bat
    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.

    PS if the play.bat code was unneeded then so be it, like i said i dont understand much.

  11. #11
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,331
    Rep Power
    25

    Default

    i am really looking for a fix rather than this workaround.

    running it normally
    I run java programs all the time by having shortcuts that execute the command: java -jar filename.jar
    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?

  12. #12
    illjavathat is offline Member
    Join Date
    Jun 2010
    Posts
    29
    Rep Power
    0

    Default

    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.

  13. #13
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,949
    Rep Power
    19

    Default

    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.

  14. #14
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,331
    Rep Power
    25

    Default

    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?

  15. #15
    illjavathat is offline Member
    Join Date
    Jun 2010
    Posts
    29
    Rep Power
    0

    Default

    Quote Originally Posted by Norm View Post
    What is displayed in the Type column in Windows Explorer for jar files?
    Jar File... hmm how to fix...?
    and no as i said in my first and many other posts lol that is the problem, by running (clicking/opening) the jar file it gives the main class error.

  16. #16
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,331
    Rep Power
    25

    Default

    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.

    it gives the main class error.
    Where did you post the Full contents of this error message? I can't see it. See my post#9

    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".

  17. #17
    illjavathat is offline Member
    Join Date
    Jun 2010
    Posts
    29
    Rep Power
    0

    Default

    i have tried reinstalling java. http://dl.dropbox.com/u/120327/javaerror2.jpg is the full error.

  18. #18
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,331
    Rep Power
    25

    Default

    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.

  19. #19
    illjavathat is offline Member
    Join Date
    Jun 2010
    Posts
    29
    Rep Power
    0

    Default

    Quote Originally Posted by Norm View Post
    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:
    the window is from javaw.exe which is what im trying to run the jarfile from.
    i could not find device types for changing to a cmd line... even after etensive googling lol.
    btw i had some problems but eventually redownloaded AGAIN java and jdk.

  20. #20
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,331
    Rep Power
    25

    Default

    i could not find device types for changing to a cmd line.
    No idea what this means. Can you explain?

    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

Page 1 of 2 12 LastLast

Similar Threads

  1. could not find main class?
    By deathnote202 in forum New To Java
    Replies: 6
    Last Post: 05-10-2010, 08:57 PM
  2. Could not find main class
    By Andyj in forum New To Java
    Replies: 2
    Last Post: 10-06-2009, 12:47 AM
  3. Cannot find Main class in Linux OS
    By msskiran in forum Eclipse
    Replies: 0
    Last Post: 04-10-2009, 02:04 AM
  4. Could not find main class - JDK 1.6
    By Syranno in forum New To Java
    Replies: 1
    Last Post: 07-25-2008, 04:07 PM
  5. JVM Could not find main class
    By banduskank in forum Advanced Java
    Replies: 2
    Last Post: 06-24-2008, 08:05 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •