I’m running the following code on Ubuntu 10.10, using OpenJDK 1.6.0_18:
package mypkg;
public class MyTest {
public static void main(final String[] args) {
System.out.println(args.length + " argument(s)");
for (final String arg : args) {
System.out.println(arg);
}
}
}
After compiling it into a Jar, I’m completely puzzled why executing the following command from the terminal returns 0 argument(s):
java -jar mytest.jar this is a test
This is my interpretation of the Java docs, stating:
java [ options ] -jar file.jar [ argument … ]
I almost have the feeling that I’m entering a wrong command in the terminal. What gives?
Edit: the MANIFEST.MF contains:
Manifest-Version 1.0
Created-By: 1.6.0_18 (Sun Microsystems Inc.)
Main-Class: mypkg.Starter
Class-Path: .
Have a look at the contents of your
META-INF/MANIFEST.MFfile; make sure yourMain-Classis using the correct class.