3

The title pretty much says it all, I am trying to get a java program (.jar file) to run from a Perl program. I read another post on Stackoverflow saying this syntax is correct:

system("java filename.jar");

However this is giving me the following error. I'm not sure if the problem is that it shows the filename as "filename/jar" instead of "filename.jar"

Exception in thread "main" java.lang.NoClassDefFoundError: filename/jar
Caused by: java.lang.ClassNotFoundException: filename.jar
        at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)

2 Answers 2

6

You need to call it as java -jar filename.jar.

If you leave out the -jar, then java thinks you're trying to run a class named filename.jar, which it tries to load from the filename/jar file. Since you don't have that file, java throws the error that you see.

Sign up to request clarification or add additional context in comments.

Comments

4

You have to use the -jar option to launch a jar.

java [ options ] -jar file.jar [ argument ... ]


Resources :

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.