hi group,
who can help me with the following error message:
I have made a class that uses the saxon classes. For the saxon classes,
I
have two seperate jarfiles; my own class resides in a .class-file
(Myclass.class). The constructor of my own class throws a
net.sf.saxon.s9api.SaxonApiException.
But I can’t get it to work, I keep getting a ‘cannot link Java class
Myclass’ message
I have made a class that uses the saxon classes. For the saxon classes, I
have two seperate jarfiles; my own class resides in a .class-file
(Myclass.class). The constructor of my own class throws a
net.sf.saxon.s9api.SaxonApiException.
But I can’t get it to work, I keep getting a ‘cannot link Java class
Myclass’ message
The Myclass.class file is in the directory from which jirb is run (‘.’).
I
found out that when I extract the saxon9sa.jar in that same directory,
the
message dissapears.
I really hope someone knows a better solution to this issue…
I have made a class that uses the saxon classes. For the saxon classes, I
have two seperate jarfiles; my own class resides in a .class-file
(Myclass.class). The constructor of my own class throws a
net.sf.saxon.s9api.SaxonApiException.
But I can’t get it to work, I keep getting a ‘cannot link Java class
Myclass’ message
I have made a class that uses the saxon classes. For the saxon classes, I
have two seperate jarfiles; my own class resides in a .class-file
(Myclass.class). The constructor of my own class throws a
net.sf.saxon.s9api.SaxonApiException.
But I can’t get it to work, I keep getting a ‘cannot link Java class
Myclass’ message
begin
a = MyClass.new
rescue
puts “Caught exception”
end
With a/MyException.class in the current directory, the program works.
Placing a/MyException.class in a jar file (jar cvf mine.jar
a/MyException.class) and moving the jar file, MyClass.class and ruby.rb
to a different directory gives the NameError problem you found.
Adding ‘mine.jar’ to the CLASSPATH before running the ruby program gets
it to work.
I couldn’t find a way to get jruby to load ‘mine.jar’ and then “MyClass”
so that “MyClass” was aware of the contents of ‘mine.jar’ (and so didn’t
throw a NameError). Is it possible?
I couldn’t find a way to get jruby to load ‘mine.jar’ and then “MyClass”
so that “MyClass” was aware of the contents of ‘mine.jar’ (and so didn’t
throw a NameError). Is it possible?
Hi Peter,
thanks for the research. I am not sure if your CLASSPATH solution will
work
for me… I run my ruby script using jruby, it is not embedded in java
(or
am I missing something?).
Since I didn’t get your CLASSPATH suggestion to work, I have rewritten
the
Myclass class in jruby and that works very well too.
But I am more than interested to know what is going wrong; I have this
feeling that my understanding of jruby isn’t complete concerning this
subject…
The line: CLASSPATH=$CLASSPATH:mine.jar adds the jar file to the current
value of CLASSPATH. This is then accessible to MyClass when you use it
in jruby.
I hope that helps.
Hi Peter,
you are right, setting CLASSPATH does work indeed. I made make
conclusion
too early. I did this:
, I would have seen that it works indeed. Thanks for the hint.
But although this is a good workaround, I find it not acceptable for an
end
solution. I am still looking for something that makes the script self
supporting.
I am not shore if this is a jruby bug and I should submit a bug report
or
not. I hope someone can advice me on this.
What did you type to try the CLASSPATH solution? You seem to be on
Linux. I did the following in a bash terminal (using my example from
above):
ls
mine.jar MyClass.class paths.rb
jruby paths.rb
paths.rb:2: cannot link Java class MyClass, probable missing dependency:
a/MyException (NameError)
CLASSPATH=$CLASSPATH:mine.jar
jruby paths.rb
Caught Exception
The line: CLASSPATH=$CLASSPATH:mine.jar adds the jar file to the current
value of CLASSPATH. This is then accessible to MyClass when you use it
in jruby.