目标不同版本的JRE [英] Target different version of JRE
问题描述
我在Windows Surface Pro上测试Java。 Surface Pro有Java 7 Update 55,但没有安装了JDK。
I'm testing Java on a Windows Surface Pro. The Surface Pro has Java 7 Update 55, but does not have the JDK installed.
我从命令行在我的MacBook上编译了一个程序使用 javac
。 MacBook有Java 8 Update 5,它包括JDK(显然是因为我在MBP上编译)。
I compiled a program on my MacBook from the command line using javac
. The MacBook Has Java 8 Update 5 and it includes the JDK (obviously because I compiled on the MBP).
当我将程序从MackBook移动到Surface Pro时,我得到以下错误。在这里,移动程序意味着将两个 *。class
文件复制到新机器并尝试执行字节代码。
When I move the program from the MackBook to the Surface Pro, I get the following error. Here, "moving the program" means copying the two *.class
files to the new machine and trying to execute the byte codes.
java.lang.UnsupportedClassVersionError: HttpsTest : Unsupported major.minor version 52.
尝试使用目标信息编译会导致:
Trying to compile with target information results in:
$ javac -target 1.7 HttpsTest.java SSLSocketFactoryEx.java
javac: target release 1.7 conflicts with default source release 1.8
javac -help
不会列出任何控制编译程序( target
除外)的版本信息的选项)。
javac -help
does not list any options to control the version information of the compiled program (other than target
, which does not appear to work).
如何为JRE的低级版本编译我的源文件?在这种情况下,我使用Java 8机器定位Java 7.。
How do I compile my source files for down level versions of a JRE? In this case, I'm targeting Java 7 from a Java 8 machine.
推荐答案
查看此页 http://docs.oracle.com/javase/8/docs/technotes/tools /windows/javac.html 特别指定源和目标选项。
See this page http://docs.oracle.com/javase/8/docs/technotes/tools/windows/javac.html especiallay the source and target options.
这篇关于目标不同版本的JRE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!