简体   繁体   English

为什么不能将JAVA_HOME和JRE_HOME设置为其他内容?

[英]Why can't I set JAVA_HOME and JRE_HOME to something else?

I'm running ubuntu and djatoka (which runs in tomcat) won't work with OpenJDK. 我正在运行ubuntu,而djatoka(在tomcat中运行)将无法与OpenJDK一起使用。 So I set JAVA_HOME and JRE_HOME to the Sun java that I downloaded and exported the variables. 因此,我将JAVA_HOME和JRE_HOME设置为我下载并导出变量的Sun java。 When I start tomcat, it reports JRE_HOME to what I set. 当我启动tomcat时,它将报告我设置的JRE_HOME。

However, when I actually look at the variables, they're pointing to OpenJDK and djatoka isn't working. 但是,当我实际查看变量时,它们指向的是OpenJDK,而djatoka无法正常工作。 I can't find anyplace where it's being hardcoded, and even when I drop the variable assignments in catalina.sh and export from there, the same thing happens. 我找不到任何对其进行硬编码的地方,即使我将变量分配放在catalina.sh中并从那里导出时,也会发生同样的事情。

What the heck is going on? 到底他妈发生了什么? Thanks, 谢谢,

kyle 凯尔

What operating system are you using? 您使用什么操作系统? Try making sure you are setting those environment variables for the entire system and not the user. 尝试确保为整个系统而不是用户设置这些环境变量。

Ubuntu uses a somewhat wired alternatives system. Ubuntu使用某种有线alternatives系统。 Program in /usr/bin point to /etc/alternatives and from there it goes to /usr/share/jdk-something. / usr / bin中的程序指向/ etc / alternatives,然后从那里转到/ usr / share / jdk-something。

There is an easy way: Uninstall the OpenJDK and GCJ. 有一个简单的方法:卸载OpenJDK和GCJ。 But you might run into dependency-issues. 但是您可能会遇到依赖关系问题。

Or read about the alternatives-system. 或阅读有关替代系统的信息。

man update-alternatives 

should help. 应该有所帮助。 It's not that hard. 没那么难。 A little complicated - that's all. 有点复杂-仅此而已。

I should add, that the benefit of the alternatives system is, that you can have multiple installations of java in parallel (1.5, 1.6, 1.7 alpha, OpenJDK) and switch with one command all the links - to java, javac, appletviewer, javap and so on. 我应该补充说,替代系统的好处是,您可以并行安装多个Java(1.5、1.6、1.7 alpha,OpenJDK),并使用一个命令切换所有链接-到Java,javac,appletviewer,javap等等。 Not to forget the CLASSPATH, afaik. 不要忘记CLASSPATH,afaik。 And Updates from 1.6.23 to 1.6.24 are handled by Ubuntu flawlessly. Ubuntu可以完美地处理从1.6.23到1.6.24的更新。 But it is annoying to trace the links down to their root. 但是将链接追溯到它们的根是很烦人的。

There is even a Java-shortcut for the alternatives: 甚至还有Java快捷方式可供选择:

update-java-alternatives --help

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

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