Windows JAVA HOME problems

家住魔仙堡 提交于 2019-12-01 20:38:42

问题


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.


回答1:


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)



回答2:


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



回答3:


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"


来源:https://stackoverflow.com/questions/1229019/windows-java-home-problems

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!