• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
Sheriffs:
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • fred rosenberger
  • Frits Walraven

Calling .js file from Java

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any way we could call Javascript function in a .js file from Java?
 
Sheriff
Posts: 67389
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Shailendra Suryawanshi
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 67389
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Without a servlet, JSP or applet, how do you expect to run this Java class as part of the web application?
 
Shailendra Suryawanshi
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rancher
Posts: 43015
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 67389
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, you should have mentioned that. Most questions here are related to web apps. I've moved this to a general Java forum.
 
I am going down to the lab. Do NOT let anyone in. Not even this tiny ad:
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic