Forum: JRuby JRuby File Ops

981557a6a5f05a7b96e9a4fea2a6ccb1?d=identicon&s=25 Gary Hasson (gary2594)
on 2011-07-23 21:25
Attachment: gui_filetest.rb (3 KB)
Attachment: filetest.rb (807 Bytes)
File operations that work in my simple JRuby program do not work in my
Swing GUI based program. The attached file "filetest.rb" reads in a text
file (itself) and sends it to the console with a "puts".

That code was copied into the other attachment "gui_filetest.rb", which
should do the same thing when triggered by my popup menu selection.

The line that causes the error follows:
#      read_from_disk # This causes an error
The error message is at the very bottom of the file,
 between =begin and =end.
981557a6a5f05a7b96e9a4fea2a6ccb1?d=identicon&s=25 Gary Hasson (gary2594)
on 2011-07-24 19:59
I found the problem, so don't bother with this.
F1d37642fdaa1662ff46e4c65731e9ab?d=identicon&s=25 Charles Nutter (headius)
on 2011-07-25 03:35
(Received via mailing list)
Sorry nobody got back to you. What was the problem?

- Charlie
981557a6a5f05a7b96e9a4fea2a6ccb1?d=identicon&s=25 Gary Hasson (gary2594)
on 2011-07-25 13:31
Hi Charles,
The problem was a simple Ruby mistake that I made. However, the error
message mentioned something relative to Java, so I thought that somehow
my Ruby file-related commands were somehow clashing with Java. After a
while, I stopped looking for Java-related issues, and then finally saw
that it was just a simple Ruby variable-scope issue.

I had been so focused on the new aspects of Java and Swing, that I got
sloppy with Ruby.

F1d37642fdaa1662ff46e4c65731e9ab?d=identicon&s=25 Charles Nutter (headius)
on 2011-07-25 21:53
(Received via mailing list)
Ok, it sounds like you may have gotten a Java error. Can you show me?
If it's a Java error/exception, that's almost always a bug; we should
be re-throwing a Ruby exception with an appropriate message. If it is
a Ruby exception but has a bad Java-related error message, that's
something we'd want to fix too.

- Charlie
981557a6a5f05a7b96e9a4fea2a6ccb1?d=identicon&s=25 Gary Hasson (gary2594)
on 2011-07-25 22:03
Here is the error msg:
Exception in thread "AWT-EventQueue-0"
org.jruby.exceptions.RaiseException: (TypeError) can't convert nil into
  at org.jruby.RubyFileTest.exist?(org/jruby/
  at TextStatus.read_from_disk(./gui_filetest.rb:30)
  at TextStatus.create_popup(./gui_filetest.rb:47)

When I looked at the error, I saw the ".java" in the error msg and
thought that perhaps Java had something to do with it. However, the
error was that my filename variable was not readable within the scope of
the class. Once I corrected that, it all worked. So Java had nothing to
do with it.
F1d37642fdaa1662ff46e4c65731e9ab?d=identicon&s=25 Charles Nutter (headius)
on 2011-07-25 22:10
(Received via mailing list)
Ahh I the issue here is that we're raising an appropriate
Ruby error, but it is eventually handled by the Java logic in the AWT
event thread. The .java files in the trace are to show the core class
methods, which are mostly implemented in Java in JRuby.

In any case, I believe this is being handled correctly by JRuby, and
it's just an interaction issue with AWT that presented it in an odd

Thank you!

- Charlie
4938d8cdccfd05a22a628a746f447fa4?d=identicon&s=25 Shobha V. (shobha_v)
on 2012-05-09 13:25
How to get full file path when trying to upload csv file.

Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.