Results 1 to 12 of 12
  1. #1
    Kaizer is offline Member
    Join Date
    Oct 2011
    Posts
    13
    Rep Power
    0

    Default Small JAR problem

    Hello all !
    I discovered how to make .jar files, using the cmd console.
    I made a .jar simply by defining the entry point class with the following syntax:
    Java Code:
    jar cfe Test.jar TimeViewer *.class
    double clicking the actual .jar file via windows explorer yields : "Cannot find the main class: TimeViewer. Program will exit." error message, but running the jar through the console with the appropriate syntax works fine. Its exactly the same if I make the Manifest.txt myself and create the .jar with
    Java Code:
    jar cfm Test.jar Manifest.txt *.class
    Fine through console but not double clicking.

    can someone please help?
    thanks! ^^

  2. #2
    2by4 is offline Banned
    Join Date
    Dec 2011
    Posts
    143
    Rep Power
    0

    Default Re: Small JAR problem

    Quote Originally Posted by Kaizer View Post
    Hello all !
    I discovered how to make .jar files, using the cmd console.
    I made a .jar simply by defining the entry point class with the following syntax:
    Java Code:
    jar cfe Test.jar TimeViewer *.class
    double clicking the actual .jar file via windows explorer yields : "Cannot find the main class: TimeViewer. Program will exit." error message, but running the jar through the console with the appropriate syntax works fine. Its exactly the same if I make the Manifest.txt myself and create the .jar with
    Java Code:
    jar cfm Test.jar Manifest.txt *.class
    Fine through console but not double clicking.

    can someone please help?
    thanks! ^^
    Does your manifest have a Main-Class entry?

    If so, is it terminated with a carriage return?

  3. #3
    Kaizer is offline Member
    Join Date
    Oct 2011
    Posts
    13
    Rep Power
    0

    Default Re: Small JAR problem

    yes, here be the content of my (self made) Manifest :

    Main-Class: TimeViewer

    and I pressed 'enter' after TimeViewer for carriage return, so its actually two lines, second one being empty but making sure the 'blinking' vertical line is at the start of the second line.

  4. #4
    2by4 is offline Banned
    Join Date
    Dec 2011
    Posts
    143
    Rep Power
    0

    Default Re: Small JAR problem

    Is there a package statement in your source?

  5. #5
    Kaizer is offline Member
    Join Date
    Oct 2011
    Posts
    13
    Rep Power
    0

    Default Re: Small JAR problem

    In the source code you mean? No, no mention of packages.
    If I change the manifest to

    Main-Class: JClock.TimeViewer

    to include the package name, it won't even run from cmd. The error message I get is
    Error:Could not find or load main class JClock.TimeViewer

    PS: I realise case sensitivity is very important and I've made sure that everything corresponds.

  6. #6
    Kaizer is offline Member
    Join Date
    Oct 2011
    Posts
    13
    Rep Power
    0

    Default Re: Small JAR problem

    arggh.. I just followed a simple video tutorial involving just one class file, I did everything same as the 'tutor', and as usual same problem. I can run the jar file from the console it launches it accordingly, but double clicking from windows explorer I keep getting the same 'Could not find the main class: Hello'
    The tutorial included showing how to make a proper manifest so I know I got it right.

  7. #7
    Kaizer is offline Member
    Join Date
    Oct 2011
    Posts
    13
    Rep Power
    0

    Default Re: Small JAR problem

    ironically, double clicking a JAR file made by someone else involving my code (so exactly the same) works.. just not when I make it.

  8. #8
    2by4 is offline Banned
    Join Date
    Dec 2011
    Posts
    143
    Rep Power
    0

    Default Re: Small JAR problem

    What does jar tf Test.jar give you?

  9. #9
    Kaizer is offline Member
    Join Date
    Oct 2011
    Posts
    13
    Rep Power
    0

    Default Re: Small JAR problem

    that gives me (working on the single class case now) :

    META-INF/
    META-INF/MANIFEST.MF
    Hello.class

  10. #10
    2by4 is offline Banned
    Join Date
    Dec 2011
    Posts
    143
    Rep Power
    0

    Default Re: Small JAR problem

    ...hmmm....so...

    When you double click a jar, it launches javaw.exe..

    Is the other persons version of Java different from yours? Do you both get the same thing with java -version

  11. #11
    2by4 is offline Banned
    Join Date
    Dec 2011
    Posts
    143
    Rep Power
    0

    Default Re: Small JAR problem

    OK, I'm off for a while..but before I go, ideas...

    1. Your version of Java is different from your version of javaw.exe

    2. If you move your jar to an empty directory, can you still run it from the command line?

    3. If you extract using jar xf Test.jar, (in your empty directory, so that you don't overwrite anything), does your manifest file have the expected entries.

  12. #12
    Kaizer is offline Member
    Join Date
    Oct 2011
    Posts
    13
    Rep Power
    0

    Default Re: Small JAR problem

    awesome, got it to work now. there was a problem in version as you guessed. I must have been confused when installing Java initially and editing the "environment"'s path, between Program Files and Program Files x86. I fixed it and updated at same time so now it shows "vers. 1.7.0_02" :)

    so I got it to work on that example I was working on, with the hello.class; and my 'JClock' =) thanks for all the help ! xD
    Last edited by Kaizer; 12-16-2011 at 08:19 PM.

Similar Threads

  1. Small problem with problem with Java, C++ parse program.
    By dragstang86 in forum New To Java
    Replies: 4
    Last Post: 10-30-2011, 04:43 AM
  2. small problem, thanks in advance for your help
    By farahm in forum New To Java
    Replies: 4
    Last Post: 11-22-2010, 10:26 AM
  3. small problem
    By rawan in forum Java Applets
    Replies: 2
    Last Post: 04-07-2010, 04:32 AM
  4. small problem
    By barusk in forum Networking
    Replies: 4
    Last Post: 03-21-2009, 07:19 AM
  5. Small problem
    By ayoood in forum New To Java
    Replies: 2
    Last Post: 06-06-2008, 01:27 PM

Posting Permissions

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