0

I am getting the below runtime exception when I try to run a Java program

Exception in thread "main" java.lang.RuntimeException: Could not load    classfile: java.util.concurrent.ConcurrentMap
at soot.coffi.Util.resolveFromClassFile(Util.java:75)
at soot.CoffiClassSource.resolve(CoffiClassSource.java:39)
at soot.SootResolver.bringToHierarchy(SootResolver.java:215)
at soot.SootResolver.bringToSignatures(SootResolver.java:239)
at soot.SootResolver.bringToBodies(SootResolver.java:280)
at soot.SootResolver.processResolveWorklist(SootResolver.java:150)
at soot.SootResolver.resolveClass(SootResolver.java:124)
at soot.Scene.tryLoadClass(Scene.java:417)
at soot.Scene.loadBasicClasses(Scene.java:990)
at soot.Scene.loadNecessaryClasses(Scene.java:1061)
at soot.Main.run(Main.java:167)
at soot.Main.main(Main.java:141)

The command used is

java -cp soot-csi.jar:../lib/soot-2.5.0.jar blah.soot.SomeClass

Since ConcurrentMap is one of the basic JRE classes, I was thinking that it is being caused by the rt.jar file not being able to be found/present in the jdk. So I checked my $JAVA_HOME variable and it does point to a JDK where the rt.jar resides inside the lib folder. So the structure is like this.

/usr/lib/jvm/java-1.7.0-openjdk.x86_64/lib/rt.jar
where $JAVA_HOME = /usr/lib/jvm/java-1.7.0-openjdk.x86_64

Anyone know how to solve this issue?

nave
  • 428
  • 5
  • 19
  • Please add the full stacktrace and the command which you are using to start the program. – Jens Jan 30 '15 at 06:34
  • What version of Java are you using? What's your main class - the one with static void main(String[] args) – Adam Jan 30 '15 at 06:36
  • Try running the same program on Java 1.7 (if you're using Java 8). – FoggyDay Jan 30 '15 at 06:37
  • I tried setting the $JAVA_HOME variable to a Java 1.7 JDK installation if that is what you mean. but, I still got the same error. – nave Jan 30 '15 at 06:41
  • Windows/Linux? How and where are you setting your environment variables..? – Adam Jan 30 '15 at 06:53
  • 1
    Try to run `/usr/lib/jvm/java-1.7.0-openjdk.x86_64/bin/java -cp ...` probably a soley `java` executes an older version. – PeterMmm Jan 30 '15 at 07:09
  • @PeterMmm Thanks, that solved it. If you want to post that as an answer, I will accept it. – nave Jan 30 '15 at 07:23
  • Out of interest try "which java" and "java -version" to see what your script was picking up... – Adam Jan 30 '15 at 07:35
  • hmm...it was using a 1.7 version of Java from Oracle...i changed to the OpenJDK version and it works. – nave Jan 30 '15 at 07:39

1 Answers1

1

Try to use absolute path to java executable like

$ /usr/lib/jvm/java-1.7.0-openjdk.x86_64/bin/java -cp ...

Probably a soley java executes an older version that do not include ConcurrentMap.

PeterMmm
  • 24,152
  • 13
  • 73
  • 111
  • You should also make sure your Linux Java configuration points to the version you want it to: `sudo /usr/sbin/alternatives --config java`: http://tech.lanesnotes.com/2008/03/using-alternatives-in-linux-to-use.html – FoggyDay Jan 30 '15 at 21:12