Building jar targeting multiple Java versions, including 9

Oliver Gondža ogondza at
Fri Aug 26 08:52:03 UTC 2016

I am about to stretch support of my project from java 6, 7 and 8 to 
version 9 as well. It does not work there out of the box as it accesses

class MyClass (in unnamed module @0x4d14b6c2) cannot access class (in module jdk.attach) because 
module jdk.attach does not export to unnamed module

Before I had a chance to experiment with introducing modules to my 
application and declaring dependency on jdk.attach, my project refuses 
to compile on java 9 as soon as I add as I instruct 
javac to produce java 6 bytecode (-target 1.6 -source 1.6):

modules are not supported in -source 1.6; use -source 9 or higher to 
enable modules

How does one take advantage of modules (in this case I have no choice) 
while keeping the project buildable for older Java versions? Or are 
users expected not to use modules until their apps drop support for 
older javas? I tried asking on SO[1] with no luck.


Thank you
Red Hat Jenkins Team

More information about the jigsaw-dev mailing list