Results 1 to 4 of 4
  1. #1
    uberketer is offline Member
    Join Date
    Jun 2011
    Posts
    2
    Rep Power
    0

    Default Jar file execution error

    Hello, I wrote a program that runs fine, however packaging the file into a jar file and trying to execute that fails.

    The project consists of three files : CinReader.java --> CinReader.class PageSource.java --> PageSource.class LocalBot.java --> LocalBot.class (main class)

    The contents of manifest.txt are : Main-Class: LocalBot.class

    I created the jar file with the command :

    C:\Users\ioil\Desktop\CSCI20\localBot>jar cvfm LocalBot.jar manifest.txt *.class

    added manifest adding: CinReader.class(in = 5908) (out= 3027)(deflated 48%) adding: LocalBot.class(in = 362) (out= 272)(deflated 24%) adding: PageSource.class(in = 5293) (out= 2560)(deflated 51%)

    C:\Users\ioil\Desktop\CSCI20\localBot>

    Now when I enter the command : "java -jar LocalBot.jar" or "LocalBot.jar" the Java Virtual Machine Launcher returns the error message : "Could not find the main class: LocalBot. Program will exit"

    Am I doing anything obviously wrong . . .

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    Is LocalBot part of a package - ie does LocalBot.java start with the line "package whatever;"? If so the package has to be mentioned in the manifest as part of the full name of the class.

    The name of the class is LocalBot (assuming there is no package) not LocalBot.class as you have in the manifest.txt file.

    The manifest.txt file should end in a newline.

  3. #3
    uberketer is offline Member
    Join Date
    Jun 2011
    Posts
    2
    Rep Power
    0

    Default Problem Solved

    I fixed it, thanks very much,

  4. #4
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

Similar Threads

  1. Replies: 6
    Last Post: 02-10-2011, 09:55 AM
  2. Replies: 10
    Last Post: 11-29-2010, 02:02 PM
  3. setColor() gives a null error on execution
    By gothrog in forum AWT / Swing
    Replies: 10
    Last Post: 09-01-2010, 02:06 AM
  4. Execution error: NoSuchMethodError: Main
    By kjharn in forum New To Java
    Replies: 4
    Last Post: 11-02-2009, 08:23 PM
  5. .BAT execution error
    By hunterbdb in forum Advanced Java
    Replies: 5
    Last Post: 02-23-2009, 05:41 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
  •