|
SageTV Studio Discussion related to the SageTV Studio application produced by SageTV. Questions, issues, problems, suggestions, etc. relating to the Studio software application should be posted here. |
|
Thread Tools | Search this Thread | Display Modes |
#1
|
||||
|
||||
Accessing JAR's From Within Sage
I'm having a problem in Sage accessing JAR information. If I had the following code:
Code:
public class MyClass { private String myName; public MyClass(String name) { myName = name; } public String GetMyName() { return myName; } public void SetMyName(String name) { myName = name; } } myVar = new_MyClass("Fred") It seems to create a valid variable (if I turn on the tracer, it shows a value of MyClass:xxxxx for myVar). According to the Studio documentation, I should be able to do the following in a statement to get the current name from the above class. MyClass_GetMyName(myVar) However, when I do that, I get an error (I can get you the specifics if necessary). I have tried various variations to get it to work, but to no avail. This class works fine with a test "main" java program I threw together. Any ideas on what I might be doing wrong? Last edited by aperry; 03-24-2006 at 01:29 AM. |
#2
|
|||
|
|||
Not sure about this, but try to put the class into a package ...
Dirk |
#3
|
||||
|
||||
Packages are not required, but help to avoid namespace collisions...
errors / console output would be useful Also turn on the error reporting in Studio.. One small point: you need to restart Sage to recognise new/updated JARs
__________________
Check out my enhancements for Sage in the Sage Customisations and Sageplugins Wiki |
#4
|
||||
|
||||
Quote:
Regarding the restarting, I have already restarted, Sage does not complain when I do the "new" statement. I already have error reporting turned on, so when I get a chance this evening, I'll report back the error I am seeing (seems to me I remember seeing something like "reflection error", or perhaps I'm just thinking of what I saw when I looked in my mirror this morning...) . Anyhow, I'll let you know. Last edited by aperry; 03-23-2006 at 01:19 PM. |
#5
|
||||
|
||||
Did you declare myVar in studio before the new statement? I had a similar problem... the new worked just fine, but the variable that it was set to did not persist, so when I went to use it, Studio didn't know what it was.
Here's the thread which resolved my problem: http://forums.freytechnologies.com/f...ad.php?t=13962 |
#6
|
||||
|
||||
The variable is actually being set up as a global as I need it in other menus, so it has been defined. It should be okay I think...
|
#7
|
||||
|
||||
"reflection error" sounds about right -- any errors from Java will trigger these, but the original error and possibly a stack trace will be reported in the logging -- if you have it enabled -- and in the troubleshooting console -- if you have it enabled
The fact that it is a reflection error suggests that your java is being called, which is a good sign, and in such a trivial class, it will probably be caused by a NullPointerException -- myVar is null..
__________________
Check out my enhancements for Sage in the Sage Customisations and Sageplugins Wiki |
#8
|
||||
|
||||
Well, I got it fixed. The class I put in the original message was just an example of what I was trying to do, the real one is a bit more complicated.
Anyhow, what happened was in the real class, I was trying to instantiate an object using the SelectedPath variable from a popup file browser selection. I figured out that SelectedPath was not a String like I originally though, rather it was a java.io.File object. I added this to my code: myFilename = java_io_File_toString(SelectedPath) Then, I used myFilename rather than SelectedPath in my code, and it all started working fine. Thanks for the pointers all, it did get me looking in the right place. The error popup did not specifically point this out, it just said that I couldn't instantiate my class. I kept trying to look at what SelectedPath was, and it was showing me the text, so I kept assuming that SelectedPath was a string. Once I figured out it was not, that solved my problem. Thanks again! |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|