0

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..

user1405417
  • 27
  • 1
  • 1
  • 8
  • Are the classes located in a JAR ? If so, add the JAR explicitly in your classpath. – Stephan Feb 01 '13 at 10:34
  • Take a look here: http://stackoverflow.com/questions/8015291/how-to-replace-com-sun-image-codec-jpeg-jpegimageencoder-in-this-code – FazoM Feb 01 '13 at 10:39
  • @Stephan by adding something like: export CLASSPATH=.:/path1:/path2:/path3:/home/user/contiki-2.6/jar_files/lib/rt.jar in the bashrc file? – user1405417 Feb 01 '13 at 10:41
  • What's the name of your jar file? – Vishal K Feb 01 '13 at 10:41
  • @VishalK the name is rt.jar, I've extracted all the libraries' folder and add that path in the CLASSPATH env-var – user1405417 Feb 01 '13 at 10:42
  • If you have all classes in `rt.jar` then better copy that jar file in lib folder and use this as classpath: `export CLASSPATH=.:/path1:/path2:/path3:/home/user/contiki-2.6/jar_files/lib/rt.jar` – Vishal K Feb 01 '13 at 10:53
  • @VishalK it is what I did, now my CLASSPATH lokks this way: export CLASSPATH=.:/path1:/path2:/path3:/home/user/contiki-2.6/jar_files/lib:/home/user/contiki-2.6/jar_files/lib/rt.jar I included the *.jar and also the un-packed libraries folder, but with no luck.. – user1405417 Feb 01 '13 at 11:08
  • Can you do one thing for testing purpose? just put `rt.jar` in the folder from where you are running `ant` command. and while executing `ant` use following `ant -lib rt.jar` – Vishal K Feb 01 '13 at 11:27
  • I'm getting the same error.. – user1405417 Feb 01 '13 at 11:34

1 Answers1

1

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.

Morty
  • 2,889
  • 2
  • 19
  • 28