简体   繁体   English

没有sudo安装jdk?

[英]Installing jdk without sudo?

Currently, I have a machine on which I am working in Eclipse, it says that the JRE System Library version is sun-jdk-1.5.0.11 but on my active development machine, it is java-6-sun-1.6.0.16. 目前,我有一台机器,我在Eclipse上工作,它说JRE系统库版本是sun-jdk-1.5.0.11,但在我的活动开发机器上,它是java-6-sun-1.6.0.16。 Is there any way I can make the first machine to use the same "java-6-sun-1.6.0.16" version without having sudo permissions on the machine? 有没有什么方法可以让第一台机器使用相同的“java-6-sun-1.6.0.16”版本,而无需在机器上使用sudo权限?

You can install the JDK in a non-standard directory, for example under your own home directory, without special permissions. 您可以将JDK安装在非标准目录中,例如在您自己的主目录下,而无需特殊权限。

You just need to point PATH and JAVA_HOME and Eclipse at it. 你只需要在它上面指向PATH和JAVA_HOME和Eclipse。

The great thing with Java on Linux (and quite some other Unices) is that you don't need the "root" password to install it. Linux上的Java(以及其他一些Unices)的优点是你不需要“root”密码来安装它。 I do this all the time. 我一直这样做。 This is in sharp contrast with Windows where, last time I checked, it was impossible to install Java without having an admin password. 这与Windows形成鲜明对比,上次我检查时,没有管理员密码就无法安装Java。

All you need is a repertory in which you put the JRE (or JDK) and then put it on the path: 您需要的只是一个库,您可以在其中放置JRE(或JDK),然后将其放在路径上:

... $ export PATH=~/jdk1.6.0_17/bin:$PATH

... $ which java
/home/wizard/jdk1.6.0_17/bin/java

... $ java -version
java version "1.6.0_17"
Java(TM) SE Runtime Environment (build 1.6.0_17-b04)
Java HotSpot(TM) Server VM (build 14.3-b01, mixed mode)

In the same vein, you can keep several JVM in the same user account and simply change the path as needed (or point your IDE to the correct JVM: for example I'm running IntelliJ IDEA with an 1.6 VM but compiling and runnning all my unit tests using a 1.5 VM). 同样,您可以将多个JVM保存在同一个用户帐户中,只需根据需要更改路径(或将IDE指向正确的JVM:例如,我使用1.6 VM运行IntelliJ IDEA但编译并运行所有JVM使用1.5 VM进行单元测试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM