Here's what I've got.
I've got my 'MyJava' folder which everything is contained in.
MyJava/src/a/HelloWorld.java MyJava/src/b/Inner.java MyJava/bin/ MyJava/manifest.txt
HelloWorld.java:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World");
Inner myInner = new Inner();
myInner.myInner();
}
}
Inner.java:
public class Inner {
public void myInner() {
System.out.println("Inner Method");
}
}
Manifest.txt:
Main-Class: HelloWorld
First I compile the .javas to .class:
javac -d bin src/a/HelloWorld.java src/b/Inner.java
Now I put these into a .jar file
jar cvfm myTwo.jar manifest.txt bin/*.class
now I try run the jar:
java -jar myTwo.jar
And I get:
Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld
...
Could not find the main class: HelloWorld. Program will exit.
I know this is a pretty simple problem, what am I missing?
pkg.name
& nameMyClass
it should be in path apkg/name/MyClass.java
. I recommend if your classes are both in the same package (the default package it seems) they should be in the same directory. There are ways to do it differently, but I suggest you stick with the simplest way for the moment. – Andrew Thompson