Question

I am trying to run a jar file, and I have created the manifest file and such within eclipse and specified the main entry point. I have tested all my class files and the one I need to work(TestRead.java) keeps giving me this error am not sure why or how to resolve it:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/ws/commons/schema/XmlSchemaElement
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
    at java.lang.Class.getMethod0(Unknown Source)
    at java.lang.Class.getMethod(Unknown Source)
    at sun.launcher.LauncherHelper.validateMainClass(Unknown Source)
    at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.apache.ws.commons.schema.XmlSchemaElement
    at java.net.URLClassLoader$1.run(Unknown Source)
    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)
        ... 6 more

And below is the command line:

java -jar JavaWdslApp.jar

Edit: I saved it as a runnable Jar file for the mean time and tried running it but another issue appears telling me the array is out of bounds: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0

This is how I call it:

public static void main(String[] args) {
String path1 = args[0];
String fileName = args[1];
TagDef tagDef;

String[] operations;
try {
    operations = listOperationsUnique("abc");
    System.out.println("operation:" + operations.length);
    for (int i = 0; i < operations.length; i++) {
        System.out.println("operation:" + operations[i]);
    }
} catch (FileNotFoundException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
} catch (SAXException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
} catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
} catch (ParserConfigurationException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}

try {
    tagDef = refheader(path1, fileName); 

    System.out.println("=================================================================");
    System.out.println("abc");
    System.out.println(abc);
    System.out.println("=================================================================");

} catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();

}
Was it helpful?

Solution

The second error is caused because you are trying to access to args[0] and args1, while you haven't informed any argument at your command line. It should look similar to this:

java -jar JavaWdslApp.jar valueForPath1 valueForFileName

I recommend you to check the java command reference.

OTHER TIPS

Problem is with your jar packaging. The jar file you created does not contains required dependencies. Please include required libs in your file while creating jar file. then you should be good to go.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top