import java in as1 (Extension) file

Post here your questions about Actionscript and Java server side extensions development.

Moderators: Lapo, Bax

bharanisasank
Posts: 7
Joined: 10 Mar 2011, 09:48
Location: India

import java in as1 (Extension) file

Postby bharanisasank » 14 Sep 2011, 05:08

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...
Sasank
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Postby rjgtav » 14 Sep 2011, 06:32

Hi. Don't forget that you have to add the jar file to the classpath.

For more information check this.
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
bharanisasank
Posts: 7
Joined: 10 Mar 2011, 09:48
Location: India

Postby bharanisasank » 14 Sep 2011, 06:49

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 ...
Sasank
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Postby rjgtav » 14 Sep 2011, 07:12

Hum... does it load the jars? for example, when you start the server, does it show "processing new jar... blablabla"
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
bharanisasank
Posts: 7
Joined: 10 Mar 2011, 09:48
Location: India

Postby bharanisasank » 14 Sep 2011, 07:30

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".
Sasank
User avatar
BigFIsh
Posts: 1698
Joined: 25 Feb 2008, 19:26
Location: New Zealand

Postby BigFIsh » 16 Sep 2011, 00:37

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.
Smartfox's forum is my daily newspaper.
bharanisasank
Posts: 7
Joined: 10 Mar 2011, 09:48
Location: India

Postby bharanisasank » 22 Sep 2011, 11:49

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
Sasank
User avatar
BigFIsh
Posts: 1698
Joined: 25 Feb 2008, 19:26
Location: New Zealand

Postby BigFIsh » 22 Sep 2011, 21:52

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();
Smartfox's forum is my daily newspaper.

Return to “Server Side Extension Development”

Who is online

Users browsing this forum: No registered users and 22 guests