windows org.jruby.Main 上的 NoClassDefFoundError
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1534977/
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
NoClassDefFoundError on org.jruby.Main
提问by dr.
I'm trying to install the hpricot gem on my Windows machine using JRuby 1.4.0RC1. I'm trying to follow the advice to the related question (see -> Installing hpricot for JRuby).
我正在尝试使用 JRuby 1.4.0RC1 在我的 Windows 机器上安装 hpricot gem。我正在尝试遵循相关问题的建议(请参阅 ->为 JRuby 安装 hpricot)。
Per the answer's advice I pulled the git head of hpricot and from it's dir ran:
根据答案的建议,我拉了 hpricot 的 git 头,并从它的目录中运行:
jruby -S rake package_jruby
cd pkg
sudo jgem install ./hpricot-0.8.1-jruby.gem
But when I run this I get the following NoClassDefFoundError:
但是当我运行它时,我得到以下 NoClassDefFoundError:
Exception in thread "main" java.lang.NoClassDefFoundError: org/jruby/Main
Caused by: java.lang.ClassNotFoundException: org.jruby.Main
at java.net.URLClassLoader.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: org.jruby.Main. Program will exit.
Apparently my JRUBY_HOME\lib\jruby.jar is getting lost.
显然我的 JRUBY_HOME\lib\jruby.jar 迷路了。
running jruby -v works fine, so I'm confused where my class path is getting messed up.
运行 jruby -v 工作正常,所以我很困惑我的类路径在哪里变得混乱。
回答by Charles Oliver Nutter
It looks like your jruby install isn't complete. Did you grab the bin
or src
dist? Check if lib/jruby.jar
exists, make sure bin/jruby
is in the same jruby location as lib/jruby.jar
, and test java -jar lib/jruby.jar -e "puts 'hello'"
to see if it's functional.
看起来您的 jruby 安装尚未完成。你抓住了bin
还是src
dist?检查是否lib/jruby.jar
存在,确保bin/jruby
与 位于相同的 jruby 位置lib/jruby.jar
,然后测试java -jar lib/jruby.jar -e "puts 'hello'"
它是否正常工作。
回答by Vladimir Dyuzhev
I suspect sudo does not inherit your environment variables. So JRUBY_HOME is gone. Try to add it to jgem profile.
我怀疑 sudo 没有继承您的环境变量。所以 JRUBY_HOME 不见了。尝试将其添加到 jgem 配置文件中。
回答by dr.
I'm on Windows. I'm not sure if JRuby 1.4 drops the 'j' prefix. jgem isn't recognized, but gem is. Regardless, when I gem environment I get:
我在 Windows 上。我不确定 JRuby 1.4 是否删除了 'j' 前缀。jgem 不被识别,但 gem 被识别。无论如何,当我 gem 环境时,我得到:
C:\tmp\hpricot>gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.5
- RUBY VERSION: 1.8.7 (2009-09-30 patchlevel 174) [java]
- INSTALLATION DIRECTORY: C:/jruby-1.4.0RC1/lib/ruby/gems/1.8
- RUBY EXECUTABLE: C:/jruby-1.4.0RC1/bin/../bin/jruby.bat
- EXECUTABLE DIRECTORY: C:/jruby-1.4.0RC1/bin/../bin
- RUBYGEMS PLATFORMS:
- ruby
- universal-java-1.6
- GEM PATHS:
- C:/jruby-1.4.0RC1/lib/ruby/gems/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- "install" => "--env-shebang"
- "update" => "--env-shebang"
- REMOTE SOURCES:
- http://gems.rubyforge.org/