Results 1 to 4 of 4

Thread: need help...success in compile with .jar, but fail in running

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2005
    Posts
    1,168

    need help...success in compile with .jar, but fail in running

    I have a jar file that contains a package. I enter this command and it compiles:

    javac -cp "C:\Program Files\Java\jdk1.5.0_05\bin\myPac.jar" app.java

    but when I try to run the program by typing this command:

    java -cp "C:\Program Files\Java\jdk1.5.0_05\bin\myPac.jar" app

    It doesn't run and i get this exception error:

    Exception in thread "main" java.lang.NoClassDefFoundError: app

    Any ideas?

  2. #2
    Frenzied Member System_Error's Avatar
    Join Date
    Apr 2004
    Posts
    1,111

    Re: need help...success in compile with .jar, but fail in running

    Does the jar file contain a manifest file?
    Not sure, but I believe you might have to specify the class file to run in a manifest file.

  3. #3
    Frenzied Member DeadEyes's Avatar
    Join Date
    Jul 2002
    Posts
    1,196

    Re: need help...success in compile with .jar, but fail in running

    Does the java command need a -jar switch to run a jar file?

  4. #4
    Frenzied Member System_Error's Avatar
    Join Date
    Apr 2004
    Posts
    1,111

    Re: need help...success in compile with .jar, but fail in running

    Yep, that's another thing you are missing.
    Your running should look like this:
    java -jar jar-file


    But you also need the Main-Class header in the manifest file to indicate the entry point to the app.

Posting Permissions

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



Click Here to Expand Forum to Full Width