Thursday, 17 January 2013

javac error using classes from rt.jar

Recently , when i tried to build a project[shopizer setup] using ant , i got a ClassnotfoundException where it could not find classes related to rt.jar in library of jre .Although , the class was present in RT.jar , but i was still getting the error. i have also included the path in ant class path :

com.sun.image.codec.jpeg.JPEGCodec can not find package 

java.lang.ClassNotFoundException JPEGCodec

the reason for this was :

when javac compiles the code , it tries to find the files in rt.jar in a symbol file called ct.sym (which is also present in lib directory). some files are missing in this symbol file.
i have to add a compile option to ignore symbol file and look directly in rt.jar.

so i have used this option -XDignore.symbol.file

for ant i put this value in javac tag

it works perfectly if you use eclipse or any other ide .
<compilerarg value="-XDignore.symbol.file" /> So , whenever you get ClassNotFoundException in using classes from rt.jar , and if the class is still present there , just try to add this argument in java compiler .