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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/786387/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 12:21:10  来源:igfitidea点击:

This is how I installed JRuby on Windows -> Why did it not work?

windowsinstalljruby

提问by Chris Collins

* 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; 

After all this, I open up cmd.exe and type jruby

完成这一切之后,我打开 cmd.exe 并输入jruby

->"The system cannot find the path specified"

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

What did I do wrong?

我做错了什么?

I removed echo_off from C:\JRuby120\bin\jruby.bat, C:\JRuby120\bin_jrubyvars.bat and C:\JRuby120\bin_jrubyvmopts.bat and invoked jruby from cmd.exe. This was the output:

我从 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" 

回答by Pesto

Well, that's what you're supposed to do. Go to the command line and enter echo %PATH%and make sure your jruby bin directory is on there.

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



EDIT:

编辑:

Ignore the above, that's not the error you'd get for jruby not being in the path. The "The system cannot find the path specified" error is because a path doesn't exist, most likely it's the path to your Java JDK. Run echo %JAVA_HOME%. Make sure that path is correct. If you don't have the Java JDK, you can download it here.

忽略上述内容,这不是 jruby 不在路径中的错误。“系统找不到指定的路径”错误是因为路径不存在,很可能是您的 Java JDK 的路径。运行echo %JAVA_HOME%。确保路径正确。如果您没有 Java JDK,可以在此处下载



EDIT 2:

编辑2:

Having seen the output of jruby.bat, the problem appears to either be in finding _jrubyvars.bat, or finding something called within it. The only thing it calls is _jrubyvmopts.bat, which doesn't call anything else. Make sure that C:\JRuby120\bin\_jrubyvars.batand C:\JRuby120\bin\_jrubyvmopts.batexist, although I can't see a reason why they shouldn't. If they both exist, then the next step would be to remove the @echo offlines from each of them and see if we can find exactly where the bad call is taking place.

看到 jruby.bat 的输出后,问题似乎出在 find_jrubyvars.bat或找到其中调用的东西。它唯一调用的是_jrubyvmopts.bat,它不调用其他任何东西。确保C:\JRuby120\bin\_jrubyvars.batC:\JRuby120\bin\_jrubyvmopts.bat存在的,虽然我不能看到一个原因,他们为什么不应该。如果它们都存在,那么下一步就是@echo off从它们中删除每条线,看看我们是否能准确找到发生错误调用的位置。



EDIT 3:

编辑 3:

Having seen all that output, it looks like JAVA_HOMEis set to "C:\Program Files\Java\jdk1.6.0_11\bin\" JAVA_HOMEshould be the parent directory: C:\Program Files\Java\jdk1.6.0_11\". Give that a try and cross your fingers this time.

看到所有输出后,看起来应该是JAVA_HOMEC:\Program Files\Java\jdk1.6.0_11\bin\JAVA_HOME应该是父目录: C:\Program Files\Java\jdk1.6.0_11\“。这次尝试一下并交叉手指。

回答by Chris Collins

Changing the value of JAVA_HOME from C:\Program Files\Java\jdk1.6.0_11\bin to C:\Program Files\Java\jdk1.6.0_11\ worked for me. My Environment: Win XP, added c:\jruby\bin to the PATH var and created JRUBY_HOME pointing to c:\jruby.

将 JAVA_HOME 的值从 C:\Program Files\Java\jdk1.6.0_11\bin 更改为 C:\Program Files\Java\jdk1.6.0_11\ 对我有用。我的环境:Win XP,将 c:\jruby\bin 添加到 PATH var 并创建指向 c:\jruby 的 JRUBY_HOME。

Thank You

谢谢你

回答by Chris Collins

I had my JAVA_HOME environment variable missing. fixing that worked for me in Windows 7

我的 JAVA_HOME 环境变量丢失了。在 Windows 7 中对我有用的修复

回答by Marc

I had the same problem and tried everything mentioned here without success.

我遇到了同样的问题,并尝试了这里提到的所有内容,但都没有成功。

My solution: reboot your PC. Worked for me!

我的解决方案:重启你的电脑。对我来说有效!