Classpath parameter works for javac but not for java (Windows)

Hello and thanks for reading,

after normal work with C #, I tried to write Java code yesterday to process the XML file. I did not use an IDE or anything else, only Notepad ++, SDK and a lot of Google :)

I needed to include some jar files for which I found out that I needed to set the classpath as a command line parameter in order to find the jar file. This worked well:

javac -cp "./metadata-extractor-2.9.1.jar;./xmpcore-5.1.2.jar" DescribeIt.java

Although using the same syntax when starting with java.exe I had less luck:

java DescribeIt -cp "./metadata-extractor-2.9.1.jar;./xmpcore-5.1.2.jar" 

Leads to

Exception in thread "main" java.lang.NoClassDefFoundError: com/drewimaging/ImageMetadataReader at DescribeIt.main(DescribeIt.java:53)
Caused by: java.lang.ClassNotFoundException: com.drew.imaging.ImageMetadataReader
        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)
        ... 1 more

When I unzip the jar files, it works fine, but I assume that jar files should not be used.

The batch code and build file can be found here.

Many thanks,

Flo

0
1

! ( ):

java -cp "metadata-extractor-2.9.1.jar;xmpcore-5.1.2.jar;." DescribeIt 
0

All Articles