怎么加参数生成低版本的class文件呐?
追答主要是 -target release 选项,不过target 和 source有关 , 所以把 -source release 也贴上来了
-source release
Specifies the version of source code accepted. The following
values for release are allowed:
1.3
The compiler does not support assertions, generics, or
other language features introduced after JDK 1.3.
1.4
The compiler accepts code containing assertions, which were
introduced in JDK 1.4.
1.5
The compiler accepts code containing generics and other
language features introduced in JDK 5. This is the default.
5 Synonym for 1.5
Note: No language changes were introduced in JDK 6, so the values
1.6 and 6 are not valid.
-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) and 1.6 (also 6).
The default for -target depends on the value of -source:
o If -source is not specified, the value of -target is 1.6
o If -source is 1.3, the value of -target is 1.1
o For all other values of -source, the value of -target is the
value of -source.
参考资料:man javac
追问额 ,还是不太明白!要不这些代码加到什么地方呐?
追答javac 编译时候的参数 类似于 -classpass 这样的
如果你用eclipse或者其他ide,可以在工程的编译选项里面找到
我是个学习java的新手,对于您说的,我还是有点不太明白,我用的是eclipse编辑的,您能说的详细点吗?具体应该怎么弄,感谢您。
追答如果要是新手的话,确实不需要去研究jar->exe 实际应用中这种比较少
因为java在桌面开发还是很少的
而且有其他的方法 让客户使用exe来启动java
或者你去看看http://jsmooth.sourceforge.net/ 这个也是用来生成exe的
我公司用这个
在工程上点右键,properties -> java Compiler -> 先启用 , 然后选择generated .class file compatlblity , 用低一些的版本就可以了