Search:

Type: Posts; User: Norm

Search: Search took 0.31 seconds.

  1. Replies
    18
    Views
    2,493

    Re: Cannot find class in .class or .jar file

    When using: java -jar HelloWorld2.jar
    the command needs to be issued in the folder containing the jar file.


    That is where the java command needs to be issued.
  2. Replies
    18
    Views
    2,493

    Re: Cannot find class in .class or .jar file

    Options passed to the java command need to start with a -
    java -jar TheJarFIlename.jar
    Otherwise the java command thinks it is the name of a class -
    Error: Could not find or load main class jar
  3. Replies
    18
    Views
    2,493

    Re: Cannot find class in .class or .jar file

    What did you do to get that message?

    Here is one way to get that error message:
  4. Replies
    18
    Views
    2,493

    Re: Cannot find class in .class or .jar file

    The posted contents of the commands that you entered did not show what directory they were entered in making it hard to judge.
    The jar command needs to be executed in the folder containing the...
  5. Replies
    18
    Views
    2,493

    Re: Cannot find class in .class or .jar file

    I can not find a simple command on my system that does what you are trying to do. I make batch files for many of my projects to create the jar file.
    Here are some examples:

    @REM Make jar file ...
  6. Replies
    18
    Views
    2,493

    Re: Cannot find class in .class or .jar file

    The Main.class file needs to be in the folder: MyPackage inside of the jar file. It looks like neither of the class files inside of the jar file are in the appropriate folder.

    The jar command...
  7. Replies
    18
    Views
    2,493

    Re: Cannot find class in .class or .jar file

    What is the contents of the package statement in the Main.java file?
    The java program is looking for Main in the package Mypackage.

    Note: Java is case sensitive. Mypackage is NOT the same as...
  8. Replies
    18
    Views
    2,493

    Re: Cannot find class in .class or .jar file

    The advantage of using correctly created jar files is that with a properly installed JRE, double-clicking on the jar file will start the java program.
    The jar file can be located anywhere. A...
  9. Replies
    18
    Views
    2,493

    Re: Cannot find class in .class or .jar file

    The full class name includes the package: com.example.helloworld.Main
    The full name needs to be given to the java command: java com.example.helloworld.Main
    The com folder needs to be in the...
Results 1 to 9 of 9