Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Launch a JAR file stored on the client PC via JSP  RSS feed

 
C Khurana
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I need to launch a JAR file stored on the client PC via the JSP page displayed at the client's browser.

Basically I am working on a web application consisting of JSP, struts and action classes.

I need to know if it is anyway possible for the JSP code to launch a JAR file;

I will pass the name and path of the JAR along with the file_name as an argument, to the JAR which it will open.
This JAR application is supposedly deployed at a previously known location on the client machine for example at
"C:\\windows\\MyFolder\\MyApp.jar". I will have to call this "MyApp.jar" via the JSP.

Is this anyways posssible??

I need this urgent. If anything like this is in your knowledge, please do help! I am sorry if I posted this in a wrong section!

Regards,
C. Khurana.
 
ramprasad madathil
Ranch Hand
Posts: 489
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jsp executes on the server (container) generating html. This html is what the client browsers receive, interpret and display. You could include some javascript in your html which the browser executes and that's pretty much the limit of what you can achieve on the client machine.
There's no way you can achive what you had posted.

Having said that, you could implement this in a different way using java webstart.
You would keep the jar file on the server (along with your web application). Provide a link through a html/jsp page that points to a jnlp file (also in your web application). This jnllp file will have details about the jar, the main class etc. When the link is clicked, java web start installed on the client box would read the jnlp file and download the jar file and execute it. It has awesome faetures like locally caching the jar file, checking for the latest version of the jar on the server etc.

Hope that helps.

cheers,
ram.
 
Ola Daniel
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To call a Jar or an executable residint on your client machine, you could do this if you have a signed applet on your JSP. Do some research on spawning processes from java:
Tip:
Process proc = Runtime.exec("java -jar c:\Blah.jar")


This is assuming you know the location of the jar file anyway.
 
Ola Daniel
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Slight correction that would be of the above
Runtime.getRuntime().exec("blah blah....");
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!