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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
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: 60050
    
  65

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: 60050
    
  65

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
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
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.


Ping & DNS - updated with new look and Ping home screen widget
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60050
    
  65

Ah, you should have mentioned that. Most questions here are related to web apps. I've moved this to a general Java forum.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Calling .js file from Java
 
Similar Threads
Calling .js from another .js
Java embedded in .JS file not working
configure tomcat to accept embedded java in .JS file
interpret java code <% ..%> in .js file
embedding Java inside html/,js file not working