Dopo aver affrontato questo problema oggi ho anche sfogliato Internet e non sono riuscito a trovare una risposta diretta. Nel mio caso non era possibile utilizzare una versione Java più alta, perché il progetto doveva essere distribuito su JDK 6. Tuttavia alla fine ho trovato la soluzione, spero che possa aiutare qualcun altro.
Il punto chiave è Java è compatibile con le versioni precedenti.
Questa è la risposta :). È possibile utilizzare una versione più alta JDK
come 1.7 or 1.8
per compilare il progetto e utilizzare l'opzione -target
per eseguire la compilazione incrociata alla versione precedente.
-target version
Generate class files that target a specified version of the VM. Class files will run on the specified target and on later versions, but not on earlier versions of the VM. Valid targets are 1.1, 1.2, 1.3, 1.4, 1.5 (also 5), 1.6 (also 6), and 1.7 (also 7).
The default for -target depends on the value of -source:
If -source is not specified, the value of -target is 1.7
If -source is 1.2, the value of -target is 1.4
If -source is 1.3, the value of -target is 1.4
If -source is 1.5, the value of -target is 1.7
If -source is 1.6, the value of -target is 1.7
For all other values of -source, the value of -target is the value of -source.
Rif: http://docs.oracle.com/javase/7/docs/technotes/tools/windows/javac.html
Stavo usando Maven così ho dovuto cambiare <java.version>
proprietà nel POM
e che è stato. Stavo ancora usando Java 8, con l'ultimo Maven tuttavia Maven era cross compilazione a JDK6.
Questa non dovrebbe essere la risposta accettata. Vedi la risposta di Nikki. http://stackoverflow.com/a/35544977/423045 – Jesse