FeaturesPluginsDocs & SupportCommunityPartners

NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

load jars in Netbans 6.1

 
Post new topic   Reply to topic    NetBeans Forums -> Ruby Users
View previous topic :: View next topic  
Author Message
Chris Kutler
Posted via mailing list.





PostPosted: Wed Jun 18, 2008 4:21 pm    Post subject: load jars in Netbans 6.1 Reply with quote

I am thinking that Erno is on the right track, or there is something
wrong with the jar.

Here is a simple test to see that all you need is to add the jar through
the Properties panel, then add include and import statements.

Download the jars from http://freetts.sourceforge.net/docs/index.php and
add the jar via the Java panel of the Properties dialog box.

put this code in your main rb

include Java
import com.sun.speech.freetts.Voice
import com.sun.speech.freetts.VoiceManager

voice = VoiceManager.getInstance.getVoice('kevin16')
voice.allocate

# Speak the text
voice.speak("title")
voice.speak("body")

Erno Mononen wrote:
Quote:
Javix wrote:
Quote:
No changes, sorry.

I had th error:

: cannot link Java class draft.Person (NameError)


So as I wrote this error might be caused by using a different version
of Java for running than with which the class was compiled. Please add
the "-w" switch to Ruby options in Project properties -> Run and post
the whole stack trace then.

Thanks,
Erno

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@ruby.netbeans.org
For additional commands, e-mail: users-help@ruby.netbeans.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@ruby.netbeans.org
For additional commands, e-mail: users-help@ruby.netbeans.org
Back to top
Javix
Posted via mailing list.





PostPosted: Thu Jun 19, 2008 7:57 am    Post subject: load jars in Netbans 6.1 Reply with quote

Hi Chris and Erno !

I tried the freets project. It works even if the source code was built with
jdk 1.4. and I had jdk 1.6 installed (that was neccesary for use the last
JRuby importation syntax). But my simple calss Person does not work!

My person_loader.rb is like that:

include Java
import draft.Person

person = Person.new
puts "person: #{person}"

And I got "D:\Netbeans projects\myJruby\lib\person_loader.rb:2: undefined
local variable or method `draft' for main:Object (NameError)"

I attached the zip containing my java project built in Eclipse 3.3.2 (really
very small..). May be t will help you to detect the reason of my errors. To
resume I use:
- jdk/jre (for Eclipse) 1.6.0_06.
- JRuby 1.1.2

%JAVA_HOME% point to the above jdk.
System variable path has: %JAVA_HOME%\bin;C:\jruby-1.1.2\bin; etc.
Thank you in advance.

--
View this message in context: http://www.nabble.com/load-jars-in-Netbans-6.1-tp17911895p17999285.html
Sent from the NetBeans Ruby - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@ruby.netbeans.org
For additional commands, e-mail: users-help@ruby.netbeans.org
Back to top
Erno Mononen
Posted via mailing list.





PostPosted: Thu Jun 19, 2008 8:07 am    Post subject: load jars in Netbans 6.1 Reply with quote

Javix wrote:
Quote:
Hi Chris and Erno !

I tried the freets project. It works even if the source code was built with
jdk 1.4. and I had jdk 1.6 installed (that was neccesary for use the last
JRuby importation syntax). But my simple calss Person does not work!


I should have been more specific about the problems with different
versions of Java - classed compiled with an older version will work
under a newer version. Your thirdparty.jar was compiled with 1.6 and
doesn't work under 1.5 or older.

Quote:
My person_loader.rb is like that:

include Java
import draft.Person

You need to use quotes here, i.e. import 'draft.Person'.

Quote:
person = Person.new
puts "person: #{person}"

And I got "D:\Netbeans projects\myJruby\lib\person_loader.rb:2: undefined
local variable or method `draft' for main:Object (NameError)"

See above - please try again with quotes.

Erno


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@ruby.netbeans.org
For additional commands, e-mail: users-help@ruby.netbeans.org
Back to top
Javix
Posted via mailing list.





PostPosted: Thu Jun 19, 2008 8:15 am    Post subject: load jars in Netbans 6.1 Reply with quote

With quotes I'va got: ": cannot link Java class draft.Person (NameError)"


Erno Mononen wrote:
Quote:

Javix wrote:
Quote:
Hi Chris and Erno !

I tried the freets project. It works even if the source code was built
with
jdk 1.4. and I had jdk 1.6 installed (that was neccesary for use the last
JRuby importation syntax). But my simple calss Person does not work!


I should have been more specific about the problems with different
versions of Java - classed compiled with an older version will work
under a newer version. Your thirdparty.jar was compiled with 1.6 and
doesn't work under 1.5 or older.

Quote:
My person_loader.rb is like that:

include Java
import draft.Person

You need to use quotes here, i.e. import 'draft.Person'.

Quote:
person = Person.new
puts "person: #{person}"

And I got "D:\Netbeans projects\myJruby\lib\person_loader.rb:2: undefined
local variable or method `draft' for main:Object (NameError)"

See above - please try again with quotes.

Erno


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@ruby.netbeans.org
For additional commands, e-mail: users-help@ruby.netbeans.org




--
View this message in context: http://www.nabble.com/load-jars-in-Netbans-6.1-tp17911895p17999591.html
Sent from the NetBeans Ruby - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@ruby.netbeans.org
For additional commands, e-mail: users-help@ruby.netbeans.org
Back to top
Erno Mononen
Posted via mailing list.





PostPosted: Thu Jun 19, 2008 8:21 am    Post subject: load jars in Netbans 6.1 Reply with quote

Javix wrote:
Quote:
With quotes I'va got: ": cannot link Java class draft.Person (NameError)"


So probably you're running it under JDK 1.5. Please try the following
step by step instructions and let us know the result:

First, open the windows console and:

1. check that you are using JDK 1.6 - type "java -version" in the console
2. check that you are using JRuby 1.1.2 - type "jruby --version"
3. create a new file called person_loader.rb and paste the following
there (assumes that you still have the jar in the same location):

include Java
require 'D:/Netbeans projects/myJruby/jars/thirdparty.jar'
import 'draft.Person'

p = Person.new
puts p


4. run the file - type "jruby -w person_loader.rb" (of course, you need
to be in the same directory where the person_loader.rb is located).
5. if that does not work, post the error here with the output from steps
1) and 2)


Thanks,
Erno

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@ruby.netbeans.org
For additional commands, e-mail: users-help@ruby.netbeans.org
Back to top
Javix
Posted via mailing list.





PostPosted: Thu Jun 19, 2008 8:45 am    Post subject: load jars in Netbans 6.1 Reply with quote

I did everything as you told me. The below are the results:

C:\Documents and Settings\be327538>java -version
java version "1.6.0_06"
Java(TM) SE Runtime Environment (build 1.6.0_06-b02)
Java HotSpot(TM) Client VM (build 10.0-b22, mixed mode, sharing)

C:\Documents and Settings\be327538>jruby -v
ruby 1.8.6 (2008-05-28 rev 6586) [x86-jruby1.1.2]

D:\Netbeans projects\myJruby\lib>jruby -w person_loader.rb
Unknown name
So it works!!! But:

If I launch it from the command line (via cmd comand in a DOS window) it
works!!!! BUT if I launch it from Netbeans by changing the run configuration
via 'Project-properties-Run' where i set:
- configuration: even if I create a new one, it will not be shown in the
list of availbale configurations when you right click on the "project-Set
configuration" menu. The only configuration is always default!! So I had to
modifiy the default configuratio by setting the main script as
person_loader.rb, ruby options as -w. And in this case it does not work and
generate an error:

------------START-----------
java.lang.UnsupportedClassVersionError: Bad version number in .class file

at java.lang.ClassLoader.defineClass1(Native Method)

at java.lang.ClassLoader.defineClass(ClassLoader.java:620)

at
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)

at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)

at java.net.URLClassLoader.access$100(URLClassLoader.java:56)

at java.net.URLClassLoader$1.run(URLClassLoader.java:195)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(URLClassLoader.java:188)

at java.lang.ClassLoader.loadClass(ClassLoader.java:306)

at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)

at java.lang.ClassLoader.loadClass(ClassLoader.java:299)

at java.lang.ClassLoader.loadClass(ClassLoader.java:251)

at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)

at java.lang.Class.forName0(Native Method)

at java.lang.Class.forName(Class.java:242)

at
org.jruby.javasupport.JavaSupport.loadJavaClass(JavaSupport.java:137)

at
org.jruby.javasupport.JavaSupport.loadJavaClassVerbose(JavaSupport.java:146)

at
org.jruby.javasupport.JavaClass.forNameVerbose(JavaClass.java:951)

at org.jruby.javasupport.JavaClass.for_name(JavaClass.java:962)

at org.jruby.javasupport.Java.get_proxy_class(Java.java:512)

at
org.jruby.javasupport.Java$JavaUtilities.get_proxy_class(Java.java:180)

at
org.jruby.javasupport.Java$JavaUtilitiesInvoker$get_proxy_class_s_method_1_0.call(Unknown
Source)

at
org.jruby.runtime.CallSite$InlineCachingCallSite.cacheAndCall(CallSite.java:155)

at
org.jruby.runtime.CallSite$InlineCachingCallSite.call(CallSite.java:332)

at
org.jruby.evaluator.ASTInterpreter.callNode(ASTInterpreter.java:649)

at
org.jruby.evaluator.ASTInterpreter.evalInternal(ASTInterpreter.java:324)

at
org.jruby.evaluator.ASTInterpreter.constDeclNode(ASTInterpreter.java:853)

at
org.jruby.evaluator.ASTInterpreter.evalInternal(ASTInterpreter.java:340)

at
org.jruby.evaluator.ASTInterpreter.rootNode(ASTInterpreter.java:1654)

at
org.jruby.evaluator.ASTInterpreter.evalInternal(ASTInterpreter.java:474)

at org.jruby.evaluator.ASTInterpreter.eval(ASTInterpreter.java:170)

at
org.jruby.evaluator.ASTInterpreter.evalWithBinding(ASTInterpreter.java:224)

at org.jruby.RubyKernel.eval(RubyKernel.java:814)

at org.jruby.RubyKernelInvoker$eval_s_method_0_3.call(Unknown
Source)

at
org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:66)

at
org.jruby.runtime.CallSite$InlineCachingCallSite.cacheAndCall(CallSite.java:107)

at
org.jruby.runtime.CallSite$InlineCachingCallSite.call(CallSite.java:264)

at
org.jruby.evaluator.ASTInterpreter.fCallNode(ASTInterpreter.java:1134)

at
org.jruby.evaluator.ASTInterpreter.evalInternal(ASTInterpreter.java:370)

at
org.jruby.evaluator.ASTInterpreter.blockNode(ASTInterpreter.java:620)

at
org.jruby.evaluator.ASTInterpreter.evalInternal(ASTInterpreter.java:318)

at org.jruby.evaluator.ASTInterpreter.eval(ASTInterpreter.java:170)

at
org.jruby.runtime.InterpretedBlock.yield(InterpretedBlock.java:150)

at
org.jruby.runtime.InterpretedBlock.yield(InterpretedBlock.java:115)

at org.jruby.runtime.Block.yield(Block.java:109)

at org.jruby.RubyArray.each(RubyArray.java:1311)

at org.jruby.RubyArrayInvoker$each_method_0_0.call(Unknown Source)

at
org.jruby.internal.runtime.methods.JavaMethod$JavaMethodZeroBlock.call(JavaMethod.java:295)

at
org.jruby.runtime.CallSite$InlineCachingCallSite.cacheAndCall(CallSite.java:91)

at
org.jruby.runtime.CallSite$InlineCachingCallSite.call(CallSite.java:278)

at
org.jruby.evaluator.ASTInterpreter.callNode(ASTInterpreter.java:675)

at
org.jruby.evaluator.ASTInterpreter.evalInternal(ASTInterpreter.java:324)

at
org.jruby.evaluator.ASTInterpreter.blockNode(ASTInterpreter.java:620)

at
org.jruby.evaluator.ASTInterpreter.evalInternal(ASTInterpreter.java:318)

at org.jruby.evaluator.ASTInterpreter.eval(ASTInterpreter.java:170)

at
org.jruby.internal.runtime.methods.DefaultMethod.interpretedCall(DefaultMethod.java:174)

at
org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:150)

at
org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:204)

at
org.jruby.runtime.CallSite$InlineCachingCallSite.cacheAndCall(CallSite.java:107)

at
org.jruby.runtime.CallSite$InlineCachingCallSite.call(CallSite.java:264)

at
org.jruby.evaluator.ASTInterpreter.fCallNode(ASTInterpreter.java:1134)

at
org.jruby.evaluator.ASTInterpreter.evalInternal(ASTInterpreter.java:370)

at org.jruby.evaluator.ASTInterpreter.eval(ASTInterpreter.java:170)

at
org.jruby.internal.runtime.methods.DefaultMethod.interpretedCall(DefaultMethod.java:174)

at
org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:150)

at
org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:267)

at
org.jruby.internal.runtime.methods.AliasMethod.call(AliasMethod.java:64)

at
org.jruby.runtime.CallSite$InlineCachingCallSite.cacheAndCall(CallSite.java:155)

at
org.jruby.runtime.CallSite$InlineCachingCallSite.call(CallSite.java:332)

at
ruby.D_3a_.Netbeans_20_projects.myJruby.lib.person_loader.__file__(D:\Netbeans
projects\myJruby\lib\person_loader.rb:3)

at
ruby.D_3a_.Netbeans_20_projects.myJruby.lib.person_loader.__file__(D:\Netbeans
projects\myJruby\lib\person_loader.rb)

at
ruby.D_3a_.Netbeans_20_projects.myJruby.lib.person_loader.load(D:\Netbeans
projects\myJruby\lib\person_loader.rb)

at org.jruby.Ruby.runScript(Ruby.java:512)

at org.jruby.Ruby.runNormally(Ruby.java:432)

at org.jruby.Ruby.runFromMain(Ruby.java:312)

at org.jruby.Main.run(Main.java:144)

at org.jruby.Main.run(Main.java:89)

at org.jruby.Main.main(Main.java:80)

: cannot link Java class draft.Person (NameError)
-------------------END-----------------------
That is not the first time when I see the difference in execution of Ruby or
JRuby scripts via cmd command ad Netbeans interface. Thank you for you help.
But nevertheless I would like to know if it is possible to resolve this
inconvenience of execution.
--
View this message in context: http://www.nabble.com/load-jars-in-Netbans-6.1-tp17911895p18000196.html
Sent from the NetBeans Ruby - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@ruby.netbeans.org
For additional commands, e-mail: users-help@ruby.netbeans.org
Back to top
Erno Mononen
Posted via mailing list.





PostPosted: Thu Jun 19, 2008 11:28 am    Post subject: load jars in Netbans 6.1 Reply with quote

Javix wrote:
Quote:
I did everything as you told me. The below are the results:

C:\Documents and Settings\be327538>java -version
java version "1.6.0_06"
Java(TM) SE Runtime Environment (build 1.6.0_06-b02)
Java HotSpot(TM) Client VM (build 10.0-b22, mixed mode, sharing)

C:\Documents and Settings\be327538>jruby -v
ruby 1.8.6 (2008-05-28 rev 6586) [x86-jruby1.1.2]

D:\Netbeans projects\myJruby\lib>jruby -w person_loader.rb
Unknown name
So it works!!! But:

If I launch it from the command line (via cmd comand in a DOS window) it
works!!!! BUT if I launch it from Netbeans by changing the run configuration
via 'Project-properties-Run' where i set:
- configuration: even if I create a new one, it will not be shown in the
list of availbale configurations when you right click on the "project-Set
configuration" menu. The only configuration is always default!! So I had to
modifiy the default configuratio by setting the main script as
person_loader.rb, ruby options as -w. And in this case it does not work and
generate an error:


OK, there is more than one way to solve this, but for example the
following should work:

Please find the netbeans.conf file, which is located in [your netbeans
install dir]\etc\netbeans.conf. Then uncomment the following line

#netbeans_jdkhome="/path/to/jdk"

and make sure that it points to JDK 6 installation, e.g.

netbeans_jdkhome="/path/to/jdk1.6.0_10"

After that restart the IDE and try to run the file again. This should
work since by default JRuby will run with the same JDK as the IDE.
Alternatively you can set the 'jruby.java.home' system property as
described in http://wiki.netbeans.org/FaqHowToCallJavaFromRuby.

HTH,
Erno


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@ruby.netbeans.org
For additional commands, e-mail: users-help@ruby.netbeans.org
Back to top
Javix
Posted via mailing list.





PostPosted: Thu Jun 19, 2008 12:02 pm    Post subject: load jars in Netbans 6.1 Reply with quote

YESSSSS !

It was that. I modified the etc/netbeans.conf file because it pointed to jdk
1.5. It's because I had installed Netbeans before installation of jdk1.6.
After that change everything work fine.
And no need to require thet jar, - its adding to the classpath via
Project-Properties-Java was recongnised !
So I deleted the line:

require 'D:/Netbeans projects/myJruby/jars/thirdparty.jar'

THANKS A LOT !!!
--
View this message in context: http://www.nabble.com/load-jars-in-Netbans-6.1-tp17911895p18007407.html
Sent from the NetBeans Ruby - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@ruby.netbeans.org
For additional commands, e-mail: users-help@ruby.netbeans.org
Back to top
Erno Mononen
Posted via mailing list.





PostPosted: Thu Jun 19, 2008 12:18 pm    Post subject: load jars in Netbans 6.1 Reply with quote

You're welcome, glad to hear you got it working.

Erno

Javix wrote:
Quote:
YESSSSS !

It was that. I modified the etc/netbeans.conf file because it pointed to jdk
1.5. It's because I had installed Netbeans before installation of jdk1.6.
After that change everything work fine.
And no need to require thet jar, - its adding to the classpath via
Project-Properties-Java was recongnised !
So I deleted the line:

require 'D:/Netbeans projects/myJruby/jars/thirdparty.jar'

THANKS A LOT !!!



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@ruby.netbeans.org
For additional commands, e-mail: users-help@ruby.netbeans.org
Back to top
Chris Kutler
Posted via mailing list.





PostPosted: Thu Jun 19, 2008 3:40 pm    Post subject: load jars in Netbans 6.1 Reply with quote

Erno Mononen wrote:

snip
Quote:
Quote:
My person_loader.rb is like that:

include Java
import draft.Person

You need to use quotes here, i.e. import 'draft.Person'.
I am curious about this rule. I do not use quotes in the hands-on-lab
and it works fine. Is there a rule about sometimes needing quotes? And
if so, when are quotes necessary?

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@ruby.netbeans.org
For additional commands, e-mail: users-help@ruby.netbeans.org
Back to top
Martin Krauskopf
Posted via mailing list.





PostPosted: Thu Jun 19, 2008 3:51 pm    Post subject: load jars in Netbans 6.1 Reply with quote

Chris Kutler wrote:
Quote:
Erno Mononen wrote:

snip
Quote:
Quote:
My person_loader.rb is like that:

include Java
import draft.Person

You need to use quotes here, i.e. import 'draft.Person'.
I am curious about this rule. I do not use quotes in the hands-on-lab
and it works fine. Is there a rule about sometimes needing quotes? And
if so, when are quotes necessary?

Quoting Charles from JRuby ML:

======
The no-quote version only supports four top-level packages: java, javax,
org, and com. This is to prevent infecting the top-level namespace with
too many methods (each of these is a method we use to drill down into
the package). The string version works with anything.

You can still load arbitrary packages like this too:

import Java::mypackage.Foo

- Charlie
======

m.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@ruby.netbeans.org
For additional commands, e-mail: users-help@ruby.netbeans.org
Back to top
Chris Kutler
Posted via mailing list.





PostPosted: Thu Jun 19, 2008 4:03 pm    Post subject: load jars in Netbans 6.1 Reply with quote

Thanks Martin. I certainly needed to learn this.

Martin Krauskopf wrote:
Quote:
Chris Kutler wrote:
Quote:
Erno Mononen wrote:

snip
Quote:
Quote:
My person_loader.rb is like that:

include Java
import draft.Person

You need to use quotes here, i.e. import 'draft.Person'.
I am curious about this rule. I do not use quotes in the hands-on-lab
and it works fine. Is there a rule about sometimes needing quotes?
And if so, when are quotes necessary?

Quoting Charles from JRuby ML:

======
The no-quote version only supports four top-level packages: java,
javax, org, and com. This is to prevent infecting the top-level
namespace with too many methods (each of these is a method we use to
drill down into the package). The string version works with anything.

You can still load arbitrary packages like this too:

import Java::mypackage.Foo

- Charlie
======

m.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@ruby.netbeans.org
For additional commands, e-mail: users-help@ruby.netbeans.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@ruby.netbeans.org
For additional commands, e-mail: users-help@ruby.netbeans.org
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> Ruby Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB