无法通过更改Java版本号在Unix中编译Jar
我在Unix中的Java代码版本是1.5,但我使用eclipse在1.5版本中开发了jar 我尝试从unix执行以下命令,但失败了无法通过更改Java版本号在Unix中编译Jar,java,eclipse,unix,Java,Eclipse,Unix,我在Unix中的Java代码版本是1.5,但我使用eclipse在1.5版本中开发了jar 我尝试从unix执行以下命令,但失败了 javac -source 1.7 -target 1.5 -bootclasspath xml_test.jar 参考: 日志: -bash-3.00$javac-source 1.5-target 1.5-bootclasspath xmltest.jar javac:没有源文件 用法:javac 可能的选择包括: -g生成所有调试信息 -g:无生成调试信息
javac -source 1.7 -target 1.5 -bootclasspath xml_test.jar
参考:
日志:
-bash-3.00$javac-source 1.5-target 1.5-bootclasspath xmltest.jar
javac:没有源文件
用法:javac
可能的选择包括:
-g生成所有调试信息
-g:无生成调试信息
-g:{lines,vars,source}只生成一些调试信息
-nowarn不生成警告
-详细输出有关编译器正在执行的操作的消息
-弃用输出使用弃用API的源位置
-类路径指定查找用户类文件的位置
-cp指定查找用户类文件的位置
-sourcepath指定查找输入源文件的位置
-引导类路径覆盖引导类文件的位置
-extdirs覆盖已安装扩展的位置
-ENDORSEDIR覆盖已认可标准路径的位置
-d指定放置生成的类文件的位置
-编码指定源文件使用的字符编码
-源提供与指定版本的源兼容性
-目标生成特定VM版本的类文件
-版本信息
-帮助打印标准选项的概要
-X打印非标准选项的概要
-J直接传递到运行时系统
你能提出一些建议吗?你在用javac处理一个jar做什么?执行只是java,javac用于编译您无法编译jar。jar(Java归档)文件是Java类文件(和其他资源)的集合,因此已经编译好了
您只能编译.java源文件。更改为编译。。请查收question@logan您需要在源文件上编译,而不是在已经编译的java归档文件(jar)上。请参阅:@logan With compileing,您需要源代码-bootclasspath引用的是JDK包中用于启动Java VM的jar,而不是您已经编译好的jar。你提到的那个问题教你如何编译一个虚拟机版本。使用javac-source 1.5-target 1.5-bootclasspath/path/to/jre1.5/lib/rt.jar进行编译。您应该替换path/to/jre而不是rt.jar您的意思是xml_test.jar吗?请参考这个问题,它不会改变事实。您仍然无法编译jar。正如在该问题的公认答案中所解释的,您需要重新编译源代码,以支持较旧的目标,或者升级unix JVM。在哪里重新编译?在Unix或eclipse中?这并不重要。我推荐Eclipse,因为它更直观。
-bash-3.00$ javac -source 1.5 -target 1.5 -bootclasspath xmltest.jar
javac: no source files
Usage: javac <options> <source files>
where possible options include:
-g Generate all debugging info
-g:none Generate no debugging info
-g:{lines,vars,source} Generate only some debugging info
-nowarn Generate no warnings
-verbose Output messages about what the compiler is doing
-deprecation Output source locations where deprecated APIs are used
-classpath <path> Specify where to find user class files
-cp <path> Specify where to find user class files
-sourcepath <path> Specify where to find input source files
-bootclasspath <path> Override location of bootstrap class files
-extdirs <dirs> Override location of installed extensions
-endorseddirs <dirs> Override location of endorsed standards path
-d <directory> Specify where to place generated class files
-encoding <encoding> Specify character encoding used by source files
-source <release> Provide source compatibility with specified release
-target <release> Generate class files for specific VM version
-version Version information
-help Print a synopsis of standard options
-X Print a synopsis of nonstandard options
-J<flag> Pass <flag> directly to the runtime system