2014-01-07 13 views
-2

我在Unix中的Java代碼版本是1.5,但是我已經使用eclipse在1.5版本中開發了該jar。不能通過更改Java來編譯Unix中的Jar版本號

我嘗試從unix執行以下命令,但失敗。

javac -source 1.7 -target 1.5 -bootclasspath xml_test.jar 

參見:How to run .jar file on unix?

登錄:

-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 

能否請您提出任何想法?

回答

1

你不能編譯一個jar文件。 jar(Java ARchive)文件是java類文件(和其他資源)的集合,因此已經被編譯。

您只能編譯.java源文件。

+0

請參閱此問題http://stackoverflow.com/questions/ 1333708/how-to-jar-file-on-unix – logan

+0

這並不改變事實。你仍然無法編譯一個罐子。正如在該問題中接受的答案中所解釋的那樣,您需要重新編譯源代碼,支持較舊的目標,或升級您的unix JVM。 –

+0

在哪裏重新編譯?在Unix或eclipse中? – logan

1

你用一個使用javac的jar做什麼?執行只是java,javac用於編譯

+0

更改爲編譯..請檢查問題 – logan

+0

@logan您需要編譯源文件而不是已編譯的java歸檔文件(jar)。 – TwilightSun

+0

請參考:http://stackoverflow.com/questions/1333708/how-to-run-jar-file-on-unix – logan

相關問題