File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Calling javascript from a java code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Calling javascript from a java code" Watch "Calling javascript from a java code" New topic

Calling javascript from a java code

madhuri madhuri
Ranch Hand

Joined: Jan 18, 2006
Posts: 58
Hi there,

Please correct me if this is not the right place to post this question.

Here is my requirement, I have a simple Java code where in I have an object and there are a number of filters that the object has to go through. The filters that I am talking about have to be editable in the sense that they have to be configurable. One of the team members here have suggested that we go for writing a javascript that does the filtering process on the object that we send in and returns a modified object.

Can anybody suggest me the ways to call a java script method from the java code to meet my requirement...?

Pl let me know if i m not clear...!!


Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15092

Have a look at the documentation for the package javax.script (new in Java 6.0).

If your version of Java is older, have a look at Rhino.
[ April 17, 2007: Message edited by: Jesper Young ]

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Roger F. Gay
Ranch Hand

Joined: Feb 16, 2007
Posts: 408
Yeah! Yeah! That was part of what I found ... couldn't remember. I was trying to suggest something about a netscape LiveConn type support in later versions of JavaScript (in the html / javascript forum during the Ajax in Practice week); but the Java calling script part was in javax.

I just want to say that this is a great topic for discussion. I'd be very active here immediately if I had more time to commit (but will do what I can whenever I can).

Excellent question. Good issue. Put this together with AJAX, and ....

Just a general comment to add ... was just identifying with another (2) questions in the distributed Java forum on RMI. Don't we all want simple two-way interactions with just about everything in every way? Whether it's javascript - java; server - client; ..... Is it just me (and apparently a few others) that could think this should be a primary issue in the development of software technology ... i.e. not just left up to millions of application developers to repeat?

I'm just asking for opinion ... I don't know if we can start a W3C standards committee from here or not.

Correlation does not prove causality.
I agree. Here's the link:
subject: Calling javascript from a java code
It's not a secret anymore!