Page 1 of 1
import java in as1 (Extension) file
Posted: 14 Sep 2011, 05:08
by bharanisasank
Hi,
I'm trying to import a java file in to a as1 Extension file..
which i was able call it successfully in my local server(in my system). but there occurs an error in the main server as follows :
Error in extension [ example.as ]: TypeError: [Java
Package RefNumberTest] is not a function, it is org.mozilla.javascript.NativeJavaPackage.
please help me in this issue...
Posted: 14 Sep 2011, 06:32
by rjgtav
Hi. Don't forget that you have to add the jar file to the classpath.
For more information check
this.
Posted: 14 Sep 2011, 06:49
by bharanisasank
rjgtav wrote:Hi. Don't forget that you have to add the jar file to the classpath.
For more information check
this.
yeah the jar files are added to the classpath already,
&
i had noticed the wrapper doesn't contain the "javaExtensions" in the class paths. & i added tat as well already...Even then it is not recognizing ...
Posted: 14 Sep 2011, 07:12
by rjgtav
Hum... does it load the jars? for example, when you start the server, does it show "processing new jar... blablabla"
Posted: 14 Sep 2011, 07:30
by bharanisasank
yeah..
and now the progress is i'm able to call the class file.. i'm getting the print statement which is written in the constructor ..
but if i try to access the function in it .. it is throwing err..
FYR:
// this is the function in the java class that i try to access..
public String getName(){
return "hai";
}
//when i try to access that file as
HelloWorldApp.getName();
// it is throwing Err as follows ..
Java class "HelloWorldApp" has no public instance field or method named "getName".
Posted: 16 Sep 2011, 00:37
by BigFIsh
is getName a static method? If not, you need to create a new instance of HelloWorldApp then call getName.
If you're new to Java or OOP, I would suggest doing some readings as use a different approach than AS1/2.
Posted: 22 Sep 2011, 11:49
by bharanisasank
BigFIsh wrote:is getName a static method? If not, you need to create a new instance of HelloWorldApp then call getName.
If you're new to Java or OOP, I would suggest doing some readings as use a different approach than AS1/2.
getName is not a static method. u can see the function which i mention in my previous post.
Note: I'm able to call the class in my local system.
The problem is when i place the class file in some other system and access it,
i'm able to get the instance of the class but while i call a method it throws error as
TypeError: getName
is not a function, it is org.mozilla.javascript.NativeJavaPackage
Posted: 22 Sep 2011, 21:52
by BigFIsh
HelloWorldApp.getName() shows that you are calling a getName static method in the class HelloWorldApp.
If getName isn't a static method, then you would do this.. var app = new HelloWorldApp(); app.getName();