• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Calling Java method from Javascript

 
Jayanth Mathavan
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I want to call a method of a standalone Java code from within a Javascript. Below is the way we can call a static method in a Java code.

var x = Packages.MyClass.add_method(5,10);

add_method() is a static method in MyClass..

Suppose I want to call a non-static method belonging to the class, how to do it? Can someone please help me out? am not using applets.

Thanks,
Jayanth Mathavan.
 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Below is the way we can call a static method in a Java code.

var x = Packages.MyClass.add_method(5,10);

Do you use var to declare a variable in Java?
Assuming that you are developing a web application, I suggest you use DWR to call server side Java code.
 
Jayanth Mathavan
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

No, I didn't use var for declaring a variable in Java. I can even use as shown below,

Packages.MyClass.add_method(5,10);

This is not a web application. This Javascript is used in one of the modules in a tool called Kettle. So I don't think it will be possible to use DWR.

Thanks,
Jayanth.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64718
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jayanth Mathavan:
This is not a web application. This Javascript is used in one of the modules in a tool called Kettle. So I don't think it will be possible to use DWR.
WOuld this not have been important information to include with the original post? Please explain your environment, most people will assume that you are working in a browser when you post a question to an HTML forum.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic