Windows JAVA HOME 问题

发布于 2024-07-29 13:55:30 字数 1618 浏览 5 评论 0原文

我正在尝试在 Windows Vista 服务器上试验 OracleHelp for Java。 我下载了 Oracle 帮助,并按照其安装说明进行操作,其中指出:

  • 将 OHJ 安装 .zip 文件解压缩到您选择的目录中
  • 确保将 JAVA_HOME 环境变量设置为兼容 Java SE 安装的位置
  • 在 OHJ 安装目录中,有一个 bin 子目录,其中包含 Windows .cmd 文件和 Unix/Linux shell 脚本。 在 Windows 平台上,双击 .cmd 文件以启动它们(或在命令行中键入 .cmd 文件名)。 在 Unix 平台上,输入“sh scriptName.sh”来执行 shell 脚本。

    • ohguide.cmd (ohguide.sh) - 启动 Oracle 帮助指南文档
    • choiceDemo.cmd (choiceDemo.sh) - 启动 Oracle 帮助功能演示
    • cshDemo.cmd (cshDemo.sh) - 启动上下文相关帮助的演示
    • helpsetDemo.cmd (helpsetDemo.sh) - 启动帮助集预览器来测试您的帮助集
    • authoringWizard.cmd (authoringWizard.bat) - 启动帮助集创作向导

当我在 Windows 上设置 JAVA_HOME 时,我可以使用或不使用引号来设置它。 无论哪种方式都会失败:

带引号:

C:\Users\Amir\Desktop\ohj-5_0_0_433\ohj-5_0_0_433\bin>set JAVA_HOME="C:\Program
Files (x86)\Java\jdk1.6.0_14"
C:\Users\Amir\Desktop\ohj-5_0_0_433\ohj-5_0_0_433\bin>ohguide.cmd
C:\Users\Amir\Desktop\ohj-5_0_0_433\ohj-5_0_0_433>""C:\Program Files (x86)\Java\
jdk1.6.0_14"\bin\java.exe" -classpath "ohj.jar;help-share.jar;oracle_ice.jar;jew
t.jar;share.jar;help-demo.jar" oracle.help.demo.ChoiceDemo "demodoc\ohguide\ohgu
ide.hs"
'""C:\Program' is not recognized as an internal or external command,
operable program or batch file.

不带引号:

C:\Users\Amir\Desktop\ohj-5_0_0_433\ohj-5_0_0_433\bin>set JAVA_HOME=C:\Prog 文件 (x86)\Java\jdk1.6.0_14

C:\Users\Amir\Desktop\ohj-5_0_0_433\ohj-5_0_0_433\bin>ohguide.cmd “文件”不被识别为内部或外部命令, 可运行的程序或批处理文件。 未找到 Java 虚拟机; 请设置JAVA_HOME环境变量。

I'm trying to experiment with OracleHelp for Java on my Windows Vista server. I downloaded Oracle help, and I'm following their installation instructions which states:

  • Unzip the OHJ installation .zip file into a directory of your choice
  • Ensure that you have the JAVA_HOME environment variable set to the location of your compatible Java SE installation
  • In the OHJ installation directory, there is a bin subdirectory containing Windows .cmd files and Unix/Linux shell scripts. On Windows platforms, double click on the .cmd files to launch them (or type the .cmd file name on the command line). On Unix platforms, type "sh scriptName.sh" to execute the shell scripts.

    • ohguide.cmd (ohguide.sh) - launches the Oracle Help Guide documentation
    • choiceDemo.cmd (choiceDemo.sh) - launches a demo of Oracle Help features
    • cshDemo.cmd (cshDemo.sh) - launches a demo of context sensitive help
    • helpsetDemo.cmd (helpsetDemo.sh) - launches the Helpset Previewer for testing your helpsets
    • authoringWizard.cmd (authoringWizard.bat) - launches the Helpset Authoring Wizard

When I set JAVA_HOME on windows I can set it with or without quotes. Either way fails :

with quotes:

C:\Users\Amir\Desktop\ohj-5_0_0_433\ohj-5_0_0_433\bin>set JAVA_HOME="C:\Program
Files (x86)\Java\jdk1.6.0_14"
C:\Users\Amir\Desktop\ohj-5_0_0_433\ohj-5_0_0_433\bin>ohguide.cmd
C:\Users\Amir\Desktop\ohj-5_0_0_433\ohj-5_0_0_433>""C:\Program Files (x86)\Java\
jdk1.6.0_14"\bin\java.exe" -classpath "ohj.jar;help-share.jar;oracle_ice.jar;jew
t.jar;share.jar;help-demo.jar" oracle.help.demo.ChoiceDemo "demodoc\ohguide\ohgu
ide.hs"
'""C:\Program' is not recognized as an internal or external command,
operable program or batch file.

without quotes:

C:\Users\Amir\Desktop\ohj-5_0_0_433\ohj-5_0_0_433\bin>set JAVA_HOME=C:\Prog
iles (x86)\Java\jdk1.6.0_14

C:\Users\Amir\Desktop\ohj-5_0_0_433\ohj-5_0_0_433\bin>ohguide.cmd
'Files' is not recognized as an internal or external command,
operable program or batch file.
No Java Virtual Machine found; please set JAVA_HOME environment variable.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

戏舞 2024-08-05 13:55:30

该问题是由 JAVA_HOME 中嵌入的空白引起的。 当我在 Windows 上安装 JDK 时,我使用不包含任何空格的目录路径覆盖安装位置。 仍然有数量惊人的工具无法处理空格。

在您的特定情况下,问题是由 _init.cmd 和 ohguide.cmd 之间不一致引起的。 在一个地方,它们在 OHJ_JAVA_HOME 的使用周围有双引号,而在另一种情况下,它们没有双引号。

但有一个解决方案 - 使用目录的缩写名称。 您可以在 DOS 窗口中使用 DIR /X 命令查找该名称。 例如,在我的系统上,“C:\Program Files”的简称为“C:\Proga~1”。 您可以在设置 JAVA_HOME 时使用此值,不带任何引号。 例如

set JAVA_HOME=c:\progra~1\java\jdk1.6.0_14

The problem is caused by the blanks embedded in your JAVA_HOME. When I install the JDK on Windows, I override the installation location with a directory path that does not contain any blanks. There are still a surprising number of tools that cannot deal with blank spaces.

In your particular case, the problem caused by an inconsistency between _init.cmd and ohguide.cmd. In one place, they have double quotes around a use of OHJ_JAVA_HOME and in the other case, they do not have double quotes.

But there is a solution - use the shortened name for the directory. You can find the name using the DIR /X command in a DOS window. For example, on my system "C:\Program Files" has the short name "C:\Proga~1". You can use this value when setting JAVA_HOME, without any quotes. e.g.

set JAVA_HOME=c:\progra~1\java\jdk1.6.0_14
酸甜透明夹心 2024-08-05 13:55:30

我在 Windows 系统属性中设置它,效果很好。

在 Vista 上:

  1. 单击“开始”按钮(Windows 徽标,左下角)
  2. 右键单击​​“计算机”
  3. 选择“属性”
  4. 选择“高级系统设置”(左侧选项)
  5. 选择“环境变量”(按钮)
  6. 添加(或编辑)系统变量 JAVA_HOME
  7. 输入您的 JAVA_HOME,不带任何内容 将任何引号
  8. 添加到 PATH 系统变量以包含 JDK 的路径(因此您不必担心如何引用它。
  9. 您可能还想扩展 CLASSPATH 系统变量以包含您在命令行上指定的变量(选修的)

I set it in Windows System Properties and that works fine.

On Vista:

  1. Click the Start button (windows logo, lower left corner)
  2. Right-Click Computer
  3. Select Properties
  4. Select Advanced system settings (options on the left)
  5. Select Environment Variables (button)
  6. Add (or edit) a System Variable JAVA_HOME
  7. Enter your JAVA_HOME without any quotes
  8. Add to the PATH System Variable to include the path to your JDK (so you dont have to worry about how to quote it.
  9. You may also want to extend your CLASSPATH System Variable to include the ones you would specify on the command line (optional)
反话 2024-08-05 13:55:30

在这两种情况下,当您尝试调用 java 可执行文件时,您都使用了太多引号。

在您的代码中:

C:\Users\Amir\Desktop\ohj-5_0_0_433\ohj-5_0_0_433>""C:\Program Files (x86)\Java\
jdk1.6.0_14"\bin\java.exe" -classpath "ohj.jar;help-share.jar;oracle_ice.jar;jew
t.jar;share.jar;help-demo.jar" oracle.help.demo.ChoiceDemo "demodoc\ohguide\ohgu
ide.hs"

应该是:

C:\Users\Amir\Desktop\ohj-5_0_0_433\ohj-5_0_0_433>"C:\Program Files (x86)\Java\
jdk1.6.0_14\bin\java.exe" -classpath "ohj.jar;help-share.jar;oracle_ice.jar;jew
t.jar;share.jar;help-demo.jar" oracle.help.demo.ChoiceDemo "demodoc\ohguide\ohgu
ide.hs"

In both scenarios you are using one too many quotes when you try to call the java exectuable.

In your code this:

C:\Users\Amir\Desktop\ohj-5_0_0_433\ohj-5_0_0_433>""C:\Program Files (x86)\Java\
jdk1.6.0_14"\bin\java.exe" -classpath "ohj.jar;help-share.jar;oracle_ice.jar;jew
t.jar;share.jar;help-demo.jar" oracle.help.demo.ChoiceDemo "demodoc\ohguide\ohgu
ide.hs"

should be:

C:\Users\Amir\Desktop\ohj-5_0_0_433\ohj-5_0_0_433>"C:\Program Files (x86)\Java\
jdk1.6.0_14\bin\java.exe" -classpath "ohj.jar;help-share.jar;oracle_ice.jar;jew
t.jar;share.jar;help-demo.jar" oracle.help.demo.ChoiceDemo "demodoc\ohguide\ohgu
ide.hs"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文