如何在 Linux 上安装 Java 开发环境(JDK、Maven、IDE...)VirtualBox
如何为 Java 开发设置基于 Unix 的 VirtualBox guest 虚拟机?我希望保留一些现有的开发环境(我运行 Windows)并使用 VirtualBox 集成它。这可能吗?
How do set up a Unix based VirtualBox guest for Java Development? I wish to keep some of my existing development environment (I run Windows) and integrate it using VirtualBox. Is this possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我花了一些时间才想出一个更灵活的解决方案,不仅可以从头开始在 Linux 上安装开发环境,还可以满足在 VirtualBox 上运行的系统。
我发现,通过在 Windows 7 Ultimate 版本上运行的 VirtualBox 运行两个系统,可以满足我作为基于 Java 的需求的最佳解决方案具有额外 bash 脚本技能的 Web 开发人员。
让我们从我的主机系统(Windows 7 Ultimate)开始,它为我提供了一个专有环境,除了 Photoshop、MS Office、MSSQL 等工具之外,我还可以在其中安装 Oracle 的专有 JDK。Windows 7 Ultimate 版本允许我进行设置XP 模式计算机将 IE6、IE7、IE8 添加到我的浏览器范围(每个旧版 Internet Explorer 都需要一台新计算机)。我还可以在 Windows 上测试 Safari,但不能在 Linux 上测试(据我所知)。我使用的大多数其他与 Java 相关的工具(IDE 和 Maven、服务器)只需解压到特定位置或运行安装程序即可。我做出的两个关键选择是: 1) 将所有内容保留在我的“%USERPROFILE%”(主)目录和目录中。 *2)*确保我的 IDE 有 Maven 支持。
我们的想法是让我们的主人和客人协调一致地工作。正如我在下面的视频中演示的那样,这两个系统可以互惠互利。我们可以在Windows中使用tortoise SVN客户端设置SVN存储库,以用作来宾系统中的存储库。显然,如果您想在 VirtualBox 中的虚拟机上安装适当的 SVN 客户端,请安装它们。但是,您的来宾 IDE 将能够使用这些 Windows 创建的存储库。您也可以采用另一种方式,即共享文件夹并使用来宾 SVN 客户端将其放入 subversion 存储库。
我们的客户系统 (Linux) 允许我们从 Windows 中删除一些过时的软件。像 FileZilla 和 FileZilla 这样的东西不再需要腻子。我们的客人配备了内置 ftp 和 ssh 的高级终端。我们现在还可以创建 bash 脚本来构建/重建我们的 Linux 开发并下载我们的需求。您甚至可以编写 bash 脚本来下载 Maven 并将其解压到 Windows 共享目录中。
Linux 还为 Web 开发人员提供了一个额外的浏览器,该浏览器需要像 Konqueror 一样进行测试。
更重要的是,我们的Linux系统可以用作与我们的主机完全不同的环境。我们可以设置 Open JDK 版本并相应地配置我们的 Maven 安装,这也可以在主机和来宾之间共享,因为 JRE 从我们的主机/来宾中抽象它。
我编写了以下脚本,用于下载 Oracle JDK 并将其安装到您的来宾、Maven、NetBeans 和 Java 上。主意。该脚本还会提示您输入一个文件来写入“boot”命令,以尝试将一些默认值(例如“.m2”、“maven”、“SVN”、“NetBeansProjects”、“IDEAProjects”)从主机安装到来宾。前提是您已使用 Guest Additions 设置 VirtualBox 并将这些目录设置为共享。
系统会提示您输入可用于写入启动命令的系统脚本文件。我希望 Linux 上有一个通用位置,但 OpenSuse 不配合,因此您将无法使用我提供的默认位置(输入:/etc/rc.d/boot.local)。如果您不喜欢此功能,脚本将在您的“/usr/local/bin”位置创建“即时”脚本。
最后,因为我们仅在来宾上使用共享文件夹(如果一切设置正确),所以删除您的来宾应该是安全的,因为您正在从主机系统共享项目、Maven、SVN,并且数据应该仍然存在。
请观看此视频
It took me some time to come up with a more flexible solution to install not only a development environment on Linux, from scratch, but also cater for a system running on VirtualBox.
I have found that running two systems through VirtualBox running on a Windows 7 Ultimate edition gives the optimal solution for my needs as a Java based web developer with additional bash scripting skills.
Let's start by my host system (Windows 7 Ultimate) provides me with a proprietary environment where I can install proprietary JDK from Oracle in addition to tools like Photoshop, MS Office, MSSQL, etc. The Ultimate version of Windows 7 allows me to set up XP Mode machines to add IE6, IE7, IE8 to my browser range (you need a new machine for each legacy Internet Explorer). I am also able to test Safari on Windows, but not Linux (to my knowledge). Most of the other tools I use related to Java (IDE's and Maven, servers), simply need to be unpacked to a specific location or a run o the installer. The two crucial choices I make are: 1) Keep everything in my "%USERPROFILE%" (home) directory & *2)*Ensure my IDE has Maven support.
The idea is to get our host and guest working in unison. The two systems can benefit each other as I demonstrate in the video below. We can set up SVN repositories with tortoise SVN client in Windows to be used as repositories in guest systems. Obviously if you want proper SVN clients on guests in VirtualBox, install them. However your guest IDE's will be able to use these Windows created repositories. You can go the other way too by sharing a folder and using your guest SVN client to make it into a subversion repository.
Our guest system (Linux), allows us to remove some bloatware from Windows. Things like FileZilla & Putty are no longer needed. Our guest comes with a superior terminal with built in ftp and ssh. We can also create bash scripts now to build/rebuild our Linux development and to download our needs. You can even write bash scripts to download and unpack Maven into a Windows shared directory.
Linux also aids the Web developer with an additional browser which needs to be tested like Konqueror.
More importantly, our Linux system can just be used as a completely different environment to our host. We can set up Open JDK versions and configure our Maven install accordingly which can also be shared between host and guest as the JRE abstracts it from our host/guest.
I have written the following script that downloads and installs Oracle JDK onto your guest, Maven, NetBeans & IDEA. The script also prompts you for a file to write 'boot' commands to in an attempt to mount some defaults like '.m2', 'maven', 'SVN', 'NetBeansProjects', 'IDEAProjects' from your host to guest. Provided that you have set up VirtualBox with Guest Additions and set up these directories to be shared.
You are prompted for your systems script file which can be used to write startup commands to. I wish there was a universal location for this on Linux but OpenSuse is not playing along so you won't be able to use the default I provided (type in: /etc/rc.d/boot.local). If you don't like this feature the script will create 'on-the-fly' scripts in your '/usr/local/bin' location.
Finally, because we are working with shared folders on the guest only (if everything is set up correctly), it should be safe to delete your guest because your are sharing projects, Maven, SVN, from host system and the data should still be there.
See this vid