Calling Java.jar from Perl using System ()

The name pretty much says it, I'm trying to run a java program (.jar file) to run from a Perl program. I read another post on Stackoverflow saying that this syntax is correct:

system("java filename.jar");

However, this gives me the following error. I'm not sure the problem is that it shows the file name 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)
+3
source share
2 answers

You must use the -jar option to run the jar.

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


Resources:

+4
source

You need to call him java -jar filename.jar.

-jar, Java , filename.jar, filename/jar. , java , .

+6

Source: https://habr.com/ru/post/1765871/


All Articles