我是「java世界」中的新成員,因此我需要了解有關不同OS和JDK中可移植性的基礎知識。我在互聯網上看到的是,如果在JDK 1.7上編譯程序,它將在任何JDK版本> = 1.7上運行,是不是?謝謝,我對我的英語表示歉意,這不是我的默認語言。Java可移植性不同OS/JDK
0
A
回答
1
現在沒有在java -target版本選項
它說,...
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), 1.6 (also 6), and 1.7 (also 7).
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.
所以「如果在JDK 1.7的編譯程序,它可以在任何版本的JDK運行> = 1.7,是對的「
+0
其中還需要指定`-source`和`-bootclasspath`選項。幸運的是,Java 7 SDK最終警告`source` /`target`沒有`bootclasspath`。 – 2011-12-16 05:43:04
0
你是對的。你寫的大多數東西都會自動工作在任何(版本兼容的)JVM中。我將一個重要的Java Swing GUI應用程序從Windows移到Linux,我只需要將配置文件更改爲指向不同的目錄。它只是工作。
0
是的,除非在新版本中棄用某些東西。棄用可能會導致一些不一致。
相關問題
- 1. fwrite可移植性
- 2. GLOB_BRACE可移植性?
- 3. Linq可移植性
- 4. 雲可移植性
- 5. Gtk/python和可移植性
- 6. dlfunc的可移植性?
- 7. std :: errc ABI可移植性
- 8. C - Glib GINT_TO_POINTER可移植性
- 9. Windows Azure - 可移植性和遷移?
- 10. 可移植性依賴scrrun.dll可用嗎?
- 11. VS2008安裝項目 - 可移植性
- 12. ConsoleKeyInfo,問號和可移植性
- 13. 什麼是陣列可移植性?
- 14. C中的open(... O_DIRECT)的可移植性?
- 15. Visual c + +「每個」可移植性
- 16. .Net Framework .resx可移植性至.Net Core
- 17. 64位可移植性問題
- 18. 的可移植性一個C代碼
- 19. std :: mem_fun表達式的可移植性
- 20. ELF共享庫可移植性
- 21. GlassFish v3 - 設置的可移植性
- 22. C中的可移植性問題
- 23. 構建系統和可移植性
- 24. Apache,PHP和MySQL的可移植性?
- 25. Solr索引的可移植性
- 26. App.config dllmap條目可移植性
- 27. Java和WCF與DateTime之間的可移植性問題
- 28. 具有最大可移植性的java遊戲
- 29. Java Swing應用程序向OSX的可移植性
- 30. Google App Engine是否具有可擴展性和可移植性?
「粗略」。當你這樣做時,你會遇到(相對較少的)不一致。我記得最常見的問題是使用「平臺默認字符集」的「新字符串(byte [])」(以及一些類似的)。只是爲了它。當你遇到一個問題......那麼,這會產生更多有趣的問題。 – 2011-12-16 05:32:07