Ich habe zwei Java-Klassen wie folgt
App1
ohne ein Paket:
class App1 {
public static void main(String[] args) {
System.out.println("App1 hello world...");
}
}
App2
in einem Paket:
package java.java.package1;
class App2 {
public static void main(String[] args) {
System.out.println("App2 hello world...");
}
}
Ich kann sie beide zusammenstellen:
D:\javaTest>javac App1.java
D:\javaTest>javac App2.java
Ich kann jedoch nur die erste ausführen:
D:\javaTest>java App1
App1 hello world...
D:\javaTest>java java.java.package1.App2
Exception in thread "main" java.lang.NoClassDefFoundError: java/java/package1/App2
Caused by: java.lang.ClassNotFoundException: java.java.package1.App2
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: java.java.package1.App2. Program will exit.
Wie kann ich die App2
?