問題描述
在虛擬機中開發 Java 有什麼好處嗎? (Are there any benefits to developing Java in a virtual machine?)
我來自 .Net 陣營,在該陣營中,虛擬化更為普遍,因為需要在服務器軟件和系統範圍的實體(如 GAC)上運行。
現在我正在做Java開發,繼續使用虛擬化有意義嗎?我們使用的是 VirtualPC,IMO 並不是最好的產品。如果我們要繼續前進,希望我們會使用 VMWare。
我們正在進行 Web 開發,不會使用虛擬化來測試不同風格的服務器部署。
優點:
- 允許整個團隊的開發環境相同
- 允許與主機隔離
- 跨平台/瀏覽器測試
缺點:
- <
## 參考解法 #### 方法 1:
One possible advantage is that you could technically test out the same program on a variety of operating systems and on a vartiety of JVMs.
Contrary to popular opinion, Java is not 100% portable, and it is very possible to write nonportable code. In addition, there are subtle versions between libraries. If you work with different JVMs, there could also be differences.
However, since Java IDEs are heavyweight, running an IDE within the VM may not be fun.
Java does support some forms of remote deployment, might be beneficial to explore those while still doing the IDE work locally.
方法 2:
I don't like developing in a VM. The good thing is, in contrast to what you're writing as cons, that multiple monitors are supported by VMWare and the huge disk thing isn't really a problem since VMWare runs surprisingly smoothly from USB hard disks.
Running the heavyweight IDEs for Java, as Uri said, won't be much fun in a VM. But then, running Visual Studio in a VM isn't really fun as well. So if you were happy with VS in a VM, then give it a try for Java, because the cons aren't as strong as you might think :)
方法 3:
You said your doing java web development so it makes sense to test your application using different web browsers on different operating systems. VMware will be useful for this.
The Netbeans IDE is operating system independent, so you can have developers working on different operating systems with out any trouble.
方法 4:
I run eclipse inside a VirtualBox instance and it works fine. I've used VMWare in the past and that's fine too.
I like having my development environment segmented away from whatever the rest of my PC is doing (playing games, surfing the web, reading email, etc...)
I work from home so virtualization provides necessary separation of work/play. It also allows me to upgrade each environment separately and have much more control over the environment.
Also I can safely try something new and revert if the install goes "wonky". Sorry for the highly technical term. ;‑)
Edit: It also allows me to satisfy the corporate VPN access requirements without subjecting my home environment to excessive corporate influence.
方法 5:
If you need a VM to verify that the app will also run on a different OS, you can cover quite some ground by using a continuous integration server and start/run VM instances on that machine (ie. Linux / Windows / OSX). Then unpack the latest build, run unit‑tests on the delivered classes. Then run automated integration tests. You will then have to report the results back to the CI‑environment. If the integration tests are good, this can catch a lot of the common multi‑platform mistakes right after they are committed to the SCM.
(by Ryan Emerle、Uri、OregonGhost、Mark、Chris Nava、kungfoo)