After reading this question I have managed to run a .jar file that had external dependencies locate in jar files:
/usr/lib/jvm/java-8-jdk/bin/java -classpath /usr/local/bin/kiaragen.jar:/home/kiara/AppLab/KIARA/kiaragen/src/main/resources/org/fiware/kiara/generator/idl/templates/*:/usr/lib/jvm/java-8-jdk/jre/lib/*:/home/kiara/AppLab/KIARA/kiaragen/lib/* org.fiware.kiara.generator.kiaragen
where /usr/local/bin/kiaragen.jar is the file to execute. Now, I'm trying to run a different version that depends on an a .class file:
/home/kiara/AppLab/KIARA/IDL-Parser/target/classes/com/eprosima/idl/parser/exception/ParseException.class
Adding the file to the classpath:
/usr/lib/jvm/java-8-jdk/bin/java -classpath /usr/local/bin/kiaragen-0.2.0.jar:/home/kiara/AppLab/KIARA/IDL-Parser/target/classes/com/eprosima/idl/parser/exception/ParseException.class:/home/kiara/AppLab/KIARA/kiaragen/src/main/resources/org/fiware/kiara/generator/idl/templates/*:/usr/lib/jvm/java-8-jdk/jre/lib/*:/home/kiara/AppLab/KIARA/kiaragen/lib/* org.fiware.kiara.generator.kiaragen
gives the following exception:
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: com/eprosima/idl/parser/exception/ParseException
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: com.eprosima.idl.parser.exception.ParseException
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 7 more
Why?
The manifest file of the .jar is the same as before:
$ cat META-INF/MANIFEST.MF
Manifest-Version: 1.0
Main-Class: org.fiware.kiara.generator.kiaragen
How can I add the .class file to the class path?