user1405417
user1405417

Reputation: 27

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: com/sun/image/codec/jpeg/JPEGCodec

So I'm working on a java-made plugin of the well known Cooja Simulator..when I click on a button, I get the exception you see in the title..
I've already read many posts related to the same issue and I have put the issuing classes in the classpath environment var, in this way (I'm working on Ubuntu):

The classes contained in "com/sun/image/codec/jpeg/JPEGCodec" are located here:

"/home/user/contiki-2.6/jar_files/lib", so that the full path is "/home/user/contiki-2.6/jar_files/lib/com/sun/image/codec/jpeg/JPEGCodec".

I've edited the bashrc file and I've inserted the following line:

export CLASSPATH=.:/path1:/path2:/path3:/home/user/contiki-2.6/jar_files/lib

Where the latter one is the path where my problematic classes are located..in the source code, the classes are imported in this way:

import com.sun.image.codec.jpeg.JPEGImageEncoder;  
import com.sun.image.codec.jpeg.JPEGCodec;  
import com.sun.image.codec.jpeg.JPEGEncodeParam;

And I make the Cooja Simulator starts using the command:
ant run

I've also tried to force the required jar/classes by issuing:

ant -lib /home/user/contiki-2.6/jar_files/lib/com/sun/image/codec/jpeg run_bigmem

but I got the same error.. Anyone who can help me to solve this issue? thanks a lot..

Upvotes: 0

Views: 2598

Answers (1)

Morty
Morty

Reputation: 3209

Cooja has its own classloader. To add additional jars add a lib-folder to your plugin and copy the jars into that folder. Then add

se.sics.cooja.GUI.JARFILES = + file1.jar file2.jar

to the cooja.config. Look at https://github.com/contiki-os/contiki/tree/master/tools/cooja/apps/mspsim as an example - here the required jars are copied by Ant.

Upvotes: 1

Related Questions