Issue
I have written a program that uses the ForkJoinPool class, this class being found in the rt.jar library in JDK 7 and the jsr166.jar library for JDK 6.
I am compiling the program in netbeans on a computer that has JDK 7 but wish the program to be usable on computers that only have JDK 6.
The Source/Binary Format used when compiling with netbeans is JDK 6. I originally compiled the program with the library rt.jar (from JDK 7) however when I ran the program originally on the JDK 6 computer I saw the error:
java.lang.SecurityException: Prohibited package name: java.util.concurrent
Following the instructions which appear on this website https://www.javacodegeeks.com/2011/02/java-forkjoin-parallel-programming.html#comment-86433.
I downloaded jsr166.jar and, having put jsr166.jar into correct directory and the Run-time libraries, attempted to use the command line:
java -Xbootclasspath/p:lib/jsr166.jar -jar code.jar $@
However this produces the error:
java.lang.UnsupportedClassVersionError: java/util/concurrent/atomic/AtomicInteger : Unsupported major.minor version 53.0
The version 53.0 alluded to, according to wikipedia is JDK version 9.
AtomicInteger is called from within teh ForkJoinPool.java class.
import java.util.concurrent.atomic.AtomicInteger;
Could anyone offer me advice on how to run this?
Thank you very much
Solution
The problem is that the file jsr166.jar - also known as Concurrency JSR-166 - that you are using was compiled with JDK 9. The ForkJoinPool is part of this API, and as you want to use it with JDK 6, you need to download a version of this API compiled for JDK 6.
The creator of this API is Dough Lea, and you will find the correct version to download from his page: http://gee.cs.oswego.edu/dl/concurrency-interest/
Repeat the procedure that you have done, now using the new jsr166.jar compiled for JDK 6, and remove the old jsr166.jar from your project.
Answered By - Alexandre V.
Answer Checked By - Timothy Miller (JavaFixing Admin)