我是「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. GLOB_BRACE可移植性?
- 2. EJB可移植性
- 3. fwrite可移植性
- 4. MinGW可移植性
- 5. Linq可移植性
- 6. 雲可移植性
- 7. JavaScriptCore可移植性
- 8. OpenCV可移植性
- 9. dlfunc的可移植性?
- 10. Gtk/python和可移植性
- 11. SQLite庫 - Python可移植性
- 12. __try和__exception可移植性
- 13. nextElementSibling/nextSibling的可移植性
- 14. Python可移植性問題
- 15. std :: errc ABI可移植性
- 16. 共享庫可移植性
- 17. C - Glib GINT_TO_POINTER可移植性
- 18. FreeTTS可移植性問題
- 19. Windows Azure - 可移植性和遷移?
- 20. 可移植性依賴scrrun.dll可用嗎?
- 21. .NET可移植性警告:CA1901 PInvoke的聲明應該是可移植
- 22. Android優化和可移植性
- 23. Berkeley DB Intel - ARM可移植性
- 24. App.config dllmap條目可移植性
- 25. $ PWD vs. pwd關於可移植性
- 26. C中的可移植性問題
- 27. Apache,PHP和MySQL的可移植性?
- 28. Visual c + +「每個」可移植性
- 29. 在Windows上的Linux pthread可移植性
- 30. Solr索引的可移植性
「粗略」。當你這樣做時,你會遇到(相對較少的)不一致。我記得最常見的問題是使用「平臺默認字符集」的「新字符串(byte [])」(以及一些類似的)。只是爲了它。當你遇到一個問題......那麼,這會產生更多有趣的問題。 – 2011-12-16 05:32:07