Java doc sagt, (Suche nach Quer Kompilierungsoptionen)
By default, classes are compiled against the bootstrap and extension classes of the
platform that javac shipped with. But javac also supports cross-compiling, where classes
are compiled against a bootstrap and extension classes of a different Java platform
implementation. It is important to use -bootclasspath and -extdirs when cross-compiling;
see Cross-Compilation Example below.
-target version
Klassendateien erzeugen, die eine bestimmte Version der VM Ziel. Klassendateien werden auf dem angegebenen Ziel und späteren Versionen ausgeführt, jedoch nicht auf früheren Versionen der VM. Gültige Ziele sind 1.1, 1.2, 1.3, 1.4, 1.5 (auch 5), 1.6 (auch 6) und 1.7 (auch 7). Die Vorgabe für -target hängt vom Wert von -Quelle:
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.
So
javac -target 1.6 -source 1.6 yourJavaProgram.java
ich dies die genaue Befehl, was u verwenden? Wenn nicht, bitte posten Sie die genauen Werte, die Sie verwenden. –
Vergessen Sie nicht, die Option -bootclasspath hinzuzufügen, um sicherzustellen, dass keine 1.6 Klassen, Methoden oder Attribute im Code verwendet werden. –
Es funktionierte so: javac-target 1.6 -source 1.6 Hello.java –