[英]Can't find MultiFormatReader class in zxing core.jar file
I'm trying to use a more current version of zxing and have tried replacing the core.jar
and javase.jar
files from the ecin/zxing gem with the 3.0 snapshot versions of those files from https://oss.sonatype.org/content/repositories/snapshots/com/google/zxing/core/ 我正在尝试使用zxing的最新版本,并尝试用来自https://oss.sonatype.org/的文件的3.0快照版本替换ecin / zxing gem中的
core.jar
和javase.jar
文件内容/库/快照/ COM /谷歌/斑马线/核心/
I'm getting a NameError
on the first class I try to reference ( com/google/zxing/MultiFormatReader
from the core.jar
file) even though the class shows up in the new jar when I do a jar -tf
. 我在尝试引用的第一个类上遇到了
NameError
(来自core.jar
文件的com/google/zxing/MultiFormatReader
),即使我执行jar -tf
时该类出现在新的jar -tf
。 The software runs file with the old jar files. 该软件使用旧的jar文件运行文件。
Any suggestions on how to debug this further? 关于如何进一步调试的任何建议?
Update : I created a new gemset with a Gemfile with only zxing in it and reproduced the same behavior, as shown below. 更新 :我创建了一个仅包含zxing的Gemfile的新gemset,并再现了相同的行为,如下所示。
MacbookAir1:javlats2 palfvin$ irb
jruby-1.7.10 :001 > require 'zxing'
NameError: missing class or uppercase package name (`com.google.zxing.MultiFormatReader')
from org/jruby/javasupport/JavaUtilities.java:54:in `get_proxy_or_package_under_package'
from file:/Users/palfvin/.rvm/rubies/jruby-1.7.10/lib/jruby.jar!/jruby/java/java_package_module_template.rb:14:in `method_missing'
from /Users/palfvin/.rvm/gems/jruby-1.7.10@javlats2/gems/zxing-0.3.1/lib/zxing/decoder.rb:12:in `ZXing'
from /Users/palfvin/.rvm/gems/jruby-1.7.10@javlats2/gems/zxing-0.3.1/lib/zxing/decoder.rb:3:in `(root)'
from org/jruby/RubyKernel.java:1083:in `require'
from /Users/palfvin/.rvm/rubies/jruby-1.7.10/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:1:in `(root)'
from /Users/palfvin/.rvm/rubies/jruby-1.7.10/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:55:in `require'
from org/jruby/RubyKernel.java:1083:in `require'
from /Users/palfvin/.rvm/gems/jruby-1.7.10@javlats2/gems/zxing-0.3.1/lib/zxing.rb:2:in `(root)'
from /Users/palfvin/.rvm/rubies/jruby-1.7.10/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:1:in `(root)'
from org/jruby/RubyKernel.java:1119:in `eval'
from /Users/palfvin/.rvm/rubies/jruby-1.7.10/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:135:in `require'
from (irb):1:in `evaluate'
from org/jruby/RubyKernel.java:1519:in `loop'
from org/jruby/RubyKernel.java:1282:in `catch'
from org/jruby/RubyKernel.java:1282:in `catch'
from /Users/palfvin/.rvm/rubies/jruby-1.7.10/bin/irb:13:in `(root)'jruby-1.7.10 :002 >
This session worked from IRB, so the class is present in the new version of the JAR: 该会话是从IRB进行的,因此该类存在于新版本的JAR中:
> require 'core-3.0.0-20140213.213916-7.jar'
> com.google.zxing.MultiFormatReader.new
=> #<Java::ComGoogleZxing::MultiFormatReader:0x6e644f41>
My guess is that you haven't replaced the JAR in the right way, somehow. 我的猜测是,某种程度上您没有以正确的方式替换JAR。 I did this to "upgrade" the JAR:
我这样做是为了“升级” JAR:
pushd ~/.rvm/gems/jruby-1.7.10/gems/zxing-0.3.1/lib/zxing/
mv core.jar orig.jar
mv ~/Downloads/core-3.0.0-20140213.213916-7.jar core.jar
Then was able to do this: 然后能够做到这一点:
> require 'zxing'
> ZXing.decode 'http://2d-code.co.uk/images/bbc-logo-in-qr-code.gif'
=> "http://bbc.co.uk/programmes"
I don't know the difference between the 2.x and 3.x APIs to be sure, but I can certainly drop in the new JAR over the old one. 我不确定2.x和3.x API之间的区别,但是我可以肯定会在旧版本中使用新的JAR。
I turns out this was related to the version of Java pointed to by my PATH variable. 我发现这与我的PATH变量指向的Java版本有关。 Even though I'd long ago installed version 7 on my mac, I'd never updated my
.bash_profile
and was picking up 6 for various command line operations. 即使我很早以前就在Mac上安装了版本7,我也从未更新过
.bash_profile
,而是为各种命令行操作选择了6。 After I changed my PATH to point to 7, the problem went away. 在我将PATH更改为指向7后,问题消失了。
There are still a few mysteries that remain, however, as follows: 但是,仍然存在一些谜团,如下所示:
-6.jar
) as if they were built for version 6, but they are no longer there (less than 24 hours later) -6.jar
)的jar文件,就好像它们是为版本6生成的一样,但不再存在(少于24小时) -6.jar
files, they failed as well -6.jar
文件时,它们也失败了
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.