这就是我在Windows上安装JRuby的方法 - >为什么它不起作用?

Chr*_*ins 3 windows install jruby

* Download JRuby 1.20. (zip file)
* Extract the zip into C:\JRuby120
* Edit sytem "environment variables":
* Add JRUBY_HOME -> point it to C:\JRuby120
* Modify the PATH environment variable to point to C:\JRuby120\bin; 
Run Code Online (Sandbox Code Playgroud)

毕竟,我打开cmd.exe并键入jruby

- >"系统找不到指定的路径"

我做错了什么?

我从C:\ JRuby120\bin\jruby.bat,C:\ JRuby120\bin_jrubyvars.bat和C:\ JRuby120\bin_jrubyvmopts.bat中删除了echo_off,并从cmd.exe调用了jruby.这是输出:

C:\>rem --------------------------------------------------------------------------- 

C:\>rem jruby.bat - Start Script for the JRuby Interpreter 

C:\>rem

C:\>rem for info on environment variables, see internal batch script _jrubyvars.bat 

C:\>setlocal

C:\>rem Sometimes, when jruby.bat is being invoked from another BAT file, 

C:\>rem C:\JRuby120\bin\ is incorrect and points to the current dir, not to JRuby's bin dir, 

C:\>rem so we look on the PATH in such cases. 

C:\>IF EXIST "C:\JRuby120\bin\_jrubyvars.bat" (set FULL_PATH=C:\JRuby120\bin\ )  ELSE (set FULL_PATH=C:\JRuby120\bin\ ) 

C:\>call "C:\JRuby120\bin\_jrubyvars.bat"  

C:\>rem Environment Variable Prequisites: 

C:\>rem

C:\>rem   JRUBY_OPTS    (Optional) Default JRuby command line args. 

C:\>rem

C:\>rem   JAVA_HOME     Must point at your Java Development Kit installation. 

C:\>rem

C:\>rem ----- Save Environment Variables That May Change -------------------------- 

C:\>set _CLASSPATH=.; 

C:\>set _CP= 

C:\>set _JRUBY_CP= 

C:\>set JRUBY_BAT_ERROR=0 

C:\>rem ----- Verify and Set Required Environment Variables ----------------------- 

C:\>if not "C:\Program Files\Java\jdk1.6.0_11\bin" == "" goto gotJava 

C:\>set JRUBY_HOME=C:\JRuby120\bin\.. 

C:\>rem ----- Prepare Appropriate Java Execution Commands ------------------------- 

C:\>if not "" == "" goto gotCommand 

C:\>set _JAVA_COMMAND= 

C:\>set JAVA_COMMAND=java 

C:\>if not "Windows_NT" == "Windows_NT" goto noTitle 

C:\>rem set _STARTJAVA=start "JRuby" "C:\Program Files\Java\jdk1.6.0_11\bin\bin\java" 

C:\>set _STARTJAVA=C:\Program Files\Java\jdk1.6.0_11\bin\bin\java 

C:\>goto gotTitle 

C:\>rem ----- Set up the VM options 

C:\>call "C:\JRuby120\bin\_jrubyvmopts"  

C:\>set _MEM=-Xmx500m 

C:\>if not defined JAVA_MEM goto memOptDone 

C:\>set _STK=-Xss1024k 

C:\>if not defined JAVA_STACK goto stackOptDone 

C:\>set _VM_OPTS= 

C:\>set _RUBY_OPTS= 

C:\>set _DFLT_VM_OPTS= 

C:\>set _JAVA_VM=-client 

C:\>set SAFE_JAVA_HOME=C:\Program Files\Java\jdk1.6.0_11\bin 

C:\>set SAFE_JAVA_HOME=C:\Program Files\Java\jdk1.6.0_11\bin 

C:\>rem

C:\>rem Can you believe I'm rewriting batch arg processing in batch files because batch 

C:\>rem file arg processing sucks so bad? Can you believe this is even possible? 

C:\>rem http://support.microsoft.com/kb/71247 

C:\>rem Escape any quotes. Use _S for ', _D for ", and _U to escape _ itself. 

C:\>rem We have to escape _ itself, otherwise file names with _S and _D 

C:\>rem will be converted to to wrong ones, when we un-escape. See JRUBY-2821. 

C:\>set _ARGS= 

C:\>if not defined _ARGS goto vmoptsDone 

C:\>set _VM_OPTS= -client -Xmx500m -Xss1024k  

C:\>set _DFLT_VM_OPTS= 

C:\>set _MEM= 

C:\>set _STK= 

C:\>set _ARGS= 

C:\>set _VAL= 

C:\>set _CMP= 

C:\>set _CMP1= 

C:\>set _JAVA_VM= 

C:\>set _RUNJAVA="C:\Program Files\Java\jdk1.6.0_11\bin\bin\java" 

C:\>rem ----- Set Up The Boot Classpath ---------------------------------------- 

C:\>for %i in ("C:\JRuby120\bin\..\lib\jruby*.jar") do @call :setjrubycp %i 

C:\>if not "" == "" goto addjrubycp 

C:\>set JRUBY_CP=C:\JRuby120\bin\..\lib\jruby.jar 

C:\>goto :EOF 

C:\>for %i in ("C:\JRuby120\bin\..\lib\bsf*.jar") do @call :setjrubycp %i 

C:\>if not "C:\JRuby120\bin\..\lib\jruby.jar" == "" goto addjrubycp 

C:\>set JRUBY_CP=C:\JRuby120\bin\..\lib\jruby.jar;C:\JRuby120\bin\..\lib\bsf.jar 

C:\>goto :EOF 

C:\>rem ----- Set Up The System Classpath ---------------------------------------- 

C:\>for %i in ("C:\JRuby120\bin\..\lib\*.jar") do @call :setcp %i 

C:\>if not "" == "" goto add 

C:\>set CP=C:\JRuby120\bin\..\lib\bsf.jar 

C:\>goto :EOF 

C:\>if not "C:\JRuby120\bin\..\lib\bsf.jar" == "" goto add 

C:\>set CP=C:\JRuby120\bin\..\lib\bsf.jar;C:\JRuby120\bin\..\lib\jruby.jar 

C:\>goto :EOF 

C:\>if not "C:\JRuby120\bin\..\lib\bsf.jar;C:\JRuby120\bin\..\lib\jruby.jar" == "" goto add 

C:\>set CP=C:\JRuby120\bin\..\lib\bsf.jar;C:\JRuby120\bin\..\lib\jruby.jar;C:\JRuby120\bin\..\lib\profile.jar 

C:\>goto :EOF 

C:\>goto :EOF 

C:\>if 0 == 0 "C:\Program Files\Java\jdk1.6.0_11\bin\bin\java"  -client -Xmx500m -Xss1024k  -Xbootclasspath/a:"C:\JRuby120\bin\..\lib\jruby.jar;C:\JRuby120\bin\..\lib\bsf.jar" -classpath "C:\JRuby120\bin\..\lib\bsf.jar;C:\JRuby120\bin\..\lib\jruby.jar;C:\JRuby120\bin\..\lib\profile.jar;.;" -Djruby.home="C:\JRuby120\bin\.." -Djruby.lib="C:\JRuby120\bin\..\lib" -Djruby.shell="cmd.exe" -Djruby.script=jruby.bat org.jruby.Main   

C:\>set E=3 

C:\>call "C:\JRuby120\bin\_jrubycleanup" 
Run Code Online (Sandbox Code Playgroud)

Pes*_*sto 11

嗯,这就是你应该做的.转到命令行并输入echo %PATH%并确保您的jruby bin目录在那里.


编辑:

忽略上面的内容,这不是你在jruby中没有出错的错误."系统找不到指定的路径"错误是因为路径不存在,很可能是它是Java JDK的路径.跑echo %JAVA_HOME%.确保路径正确.如果您没有Java JDK,可以在此处下载.


编辑2:

看过jruby.bat的输出后,问题似乎在于查找_jrubyvars.bat或查找其中的内容.它唯一要求的是_jrubyvmopts.bat,它不会调用其他任何东西.确保C:\JRuby120\bin\_jrubyvars.batC:\JRuby120\bin\_jrubyvmopts.bat存在,虽然我看不出他们不应该这样做的原因.如果它们都存在,那么下一步就是@echo off从每个线路中删除线路,看看我们是否能找到发生不良呼叫的确切位置.


编辑3:

看到所有输出后,它看起来像JAVA_HOME设置为" C:\Program Files\Java\jdk1.6.0_11\bin\" JAVA_HOME应该是父目录: C:\Program Files\Java\jdk1.6.0_11\".试试这次,然后交叉你的手指.