aspose file tools *
The moose likes Java in General and the fly likes Calling .js file from Java 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 .js file from Java" Watch "Calling .js file from Java" New topic
Author

Calling .js file from Java

Shailendra Suryawanshi
Greenhorn

Joined: May 13, 2008
Posts: 9
Is there any way we could call Javascript function in a .js file from Java?


Shailendra Suryawanshi<br /> <br />[SCJP 6]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61791
    
  67

Are you asking about Java running on the server (as part of a servlet or JSP), or as an applet on the client.

if the former, no. Please read this article to understand why.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Shailendra Suryawanshi
Greenhorn

Joined: May 13, 2008
Posts: 9
My expectation is to call a javascript function in a .js file from a normal Java class file.

I don't want to call it from jsp/servlet or applet.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61791
    
  67

Without a servlet, JSP or applet, how do you expect to run this Java class as part of the web application?
Shailendra Suryawanshi
Greenhorn

Joined: May 13, 2008
Posts: 9
It's not a web application.

I've a BPM studio which has the ability to call Java classes.

Now I wish to invoke javascript from this Java class, which now I guess is not possible.

Please comment.
Ulf Dittmer
Rancher

Joined: Mar 22, 2005
Posts: 42952
    
  73
The Rhino library lets you run JavaScript scripts from within regular Java classes. There was an article about that in the JavaRanch Journal last year.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61791
    
  67

Ah, you should have mentioned that. Most questions here are related to web apps. I've moved this to a general Java forum.
 
 
subject: Calling .js file from Java