JRuby并访问gdata类

时间:2011-02-08 05:25:35

标签: jruby gdata

我正在尝试在JRuby文件中使用Google gdata Java类。我在Windows XP上使用JRuby 1.6.0。这是我的代码:

require "java"
include Java

Dir["D:/javalib/gdata/java/lib/*.jar"].each do |jar|
  require jar
end
require 'D:/javalib/javamail-1.4.4/mail.jar'

client =
  Java::com.google.gdata.client.docs.DocsService.new("yourCo-yourAppName-v1")

这是我得到的错误:

org/jruby/javasupport/JavaUtilities.java:54:in `get_proxy_or_package_under_package': cannot link Java class com.google.gdata.client.docs.DocsService, probable missing dependency: javax/mail/MessagingException (NameError)
        from C:/jruby-1.6.0.RC1/lib/ruby/site_ruby/shared/builtin/javasupport/java.rb:51:in `method_missing'
        from download_gdocs.rb:8:in `(root)'

我很确定我是require正确的JAR文件;例如,此代码运行时没有错误:

require "java"
include Java

require 'D:/javalib/javamail-1.4.4/mail.jar'

props   = java.util.Properties.new();
session = javax.mail.Session.getDefaultInstance(props, nil);
message = javax.mail.internet.MimeMessage.new(session);

1 个答案:

答案 0 :(得分:0)

事实证明我没有在build.properties文件中添加mail.jar的路径。我想我应该按照指示......