Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Executing java file in HTML-page

 
Simon Kaali
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi gurus,
Is it possible to execute a .java or .jar or .exe file from HTML-page (with javascript?)? How?
My purpose is to start a little java program when the button or link is clicked in HTML page.
rgds,
Simon.
 
Randall Twede
Ranch Hand
Posts: 4363
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
are you talking about an applet that runs on the client? or something that runs on the server?
 
Randall Twede
Ranch Hand
Posts: 4363
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well the basic answer is yes for .class or .jar. how you do it depends on if you do it on the client (applet) or, if your server supports java, on the server (JSP or servlets). i believe you can run .exe using cgi. .java would have to be compiled first
for an applet, you can just load a different page containing the applet when the button or link is clicked. i've done that before. no javascript necessary if a link. for a button i used onclick

<input type='button' value='Sure, why not!' on_Click=\"top.frames[1].location='http://www.javaguy.dns2go.com/examples/Quiz.html'\">

(code looks a little strange because it is really part of a servlet)
(wish i could remember what the backslashes were for)
(had to add underscore for the forum to accept my post)
i had 2 buttons or i could have used <form action="URL"><input type="submit">
[ June 28, 2002: Message edited by: Randall Twede ]
[ June 28, 2002: Message edited by: Randall Twede ]
[ June 28, 2002: Message edited by: Randall Twede ]
 
Yuriy Fuksenko
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dont really understand what are you trying to do, but there is some "related" information:
if this program, that you want to start, located on a client machine, for IE you could use:
var w = new ActiveXObject('WScript.Shell');
w.Run("notepad.exe");
for NS you could use LiveConnect, and execute almost any Java code directly from JavaScript.
For both cases script should be allowed by user to do that.
If it is located a server, but you want it to run on client machine:
I never did it in NS, but in IE, if your link will point to .exe file (and for most others extension) user will choose between "Open" which will run a program and "Save". I guess in NS it something simylar.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic