How to run Jar file

hi everybody:

i have an application of jsp,,, now i have a Stand-alone-Application (Desktop application) ,, this applcation is a JAR file ok ,,, now i want to run this application from inside a jsp page ,,, in other words ,, i want to run a JAR file using any command from within a java class of from within a jsp page,,,,

thanks in advance

[359 byte] By [Eng.Mohammeda] at [2007-11-27 10:07:49]
# 1

Well I Suppose you might have to do this VIA an Applet.

and here is an example of to Invoke an Applet using JSP.

<jsp:plugin type=applet height="10%" width="10%" archive="myjarfile.jar" codebase="/applets" code="com.applets.MyApplet" >

<jsp:params>

<jsp:param name="userName" value="johndoe" />

<jsp:param name="passWord" value="p@ssword" />

</jsp:params>

<jsp:fallback>

Your Browser does not support Applets

Please,Install a JRE 5.0 +

</jsp:fallback>

</jsp:plugin>

Say your standalone Application's Class is "com.applets.MyJFrameApp"

you can invoke it via your applet class(stated above) "com.applets.MyApplet".

NOTE: One cannot Access Client System resources using either MyJFrameApp class or MyApplet class directly.Make sure you sign your applet before trying it.

Hope that might help :)

REGARDS,

RaHuL

RahulSharnaa at 2007-7-13 0:44:06 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
thnanksbut ithe jar file dont containg any applet files ,,, it is just a stand alone applciation and i want to run it ,, so this application is resides under c:\myJar.jar and i want to run this jar from inside a jsp page
Eng.Mohammeda at 2007-7-13 0:44:06 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
You may find Runtime#exec() useful. Here is the API: http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Runtime.html
BalusCa at 2007-7-13 0:44:06 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
I don't think you can do this. But I am not sure.
asgshea at 2007-7-13 0:44:06 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
You want to run the standalone app. on the client? Or server? If it's client-side, your users have to download and run it, one way or another. JSP is irrelevant, they run server-side
georgemca at 2007-7-13 0:44:06 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6
add this jar to your libraries directory (YOUR_WEB_APP/WEB-INF/lib/) then use the classes inluded in this jar like any other API.
java_2006a at 2007-7-13 0:44:06 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7
> add this jar to your libraries directory> (YOUR_WEB_APP/WEB-INF/lib/) then use the classes> inluded in this jar like any other API.I suspect he wants to run these classes client-side, but he isn't saying!
georgemca at 2007-7-13 0:44:06 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 8

i have the follwoing:

the clinet has access to my web application ok ,,,

the clinet has the jar file in his pc ,,, under c:\myJAR.jar ok...

i want from a jsp page inside my application to run that jar file which resides at client's machine not at server ,,

hope this will clearfy the picture now ,,,

thanks im regards

Eng.Mohammeda at 2007-7-13 0:44:06 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 9

> i have the follwoing:

> the clinet has access to my web application ok ,,,

> the clinet has the jar file in his pc ,,, under

> c:\myJAR.jar ok...

> i want from a jsp page inside my application to run

> that jar file which resides at client's machine not

> at server ,,

> hope this will clearfy the picture now ,,,

> thanks im regards

Can't be done. JSPs don't run on the client, they run on the server, and spit our HTML to the client. You could have the user run it through WebStart, from a link on your JSP, but you can't write JSP code to run it

georgemca at 2007-7-13 0:44:06 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 10
Ah, this way.Consider a signed applet.
BalusCa at 2007-7-13 0:44:06 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 11
how can we make this ?
Eng.Mohammeda at 2007-7-13 0:44:06 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 12
it is not an applet ,, it is a main class thanks
Eng.Mohammeda at 2007-7-13 0:44:06 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 13

a web application never launch a client application for security reason. The only script it can run is javascript (and applet..).

you have to develop a swing application that behaves like your web application but this is complex and time consuming.

could explain what should do this jar on the client side plz ?

java_2006a at 2007-7-13 0:44:06 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 14

> a web application never launch a client application

> for security reason. The only script it can run is

> javascript (and applet..).

It could never launch it because HTTP doesn't work that way. Nothing to do with security

> you have to develop a swing application that behaves

> like your web application but this is complex and

> time consuming.

>

> could explain what should do this jar on the client

> side plz ?

That's a more interesting question. What are you trying to achieve, OP?

georgemca at 2007-7-13 0:44:06 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 15
>Nothing to do with security@georgemcI meant: JAVASCRIPT can't launch an application like java do (exec...) ok ?
java_2006a at 2007-7-21 23:16:30 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 16

> >Nothing to do with security

>

> @georgemc

> I meant: JAVASCRIPT can't launch an application like

> java do (exec...) ok ?

Yeh yeh yeh, throw another tantrum because the nasty man was mean to you again. Grow up will you? These forums are peer-reviewed, it's everyone's duty to make sure people are not misled or misinformed

Sheesh, what is it with kids these days? They seem to think they have a god-given right to be wrong

georgemca at 2007-7-21 23:16:30 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 17

well well looks as if we are making a mess of everything here...

@OP

Buddie i don't think the one you wanna implement is a gud interms of security,scalablity & all other stuffs.

therefore you need to tell your client tht the one hez excepting can leads to hazards.If hez still pertained with it... here is how you can do tht....

1).Store jar files in the same classpath of your webapp and add one more jar to the archive.

<jsp:plugin type=applet height="10%" width="10%" archive="myAppletjarfile.jar,intendedJarFile.jar" codebase="/applets" code="com.applets.MyApplet" >

<jsp:params>

<jsp:param name="userName" value="johndoe" />

<jsp:param name="passWord" value="p@ssword" />

</jsp:params>

<jsp:fallback>

Your Browser does not support Applets

Please,Install a JRE 5.0 +

</jsp:fallback>

</jsp:plugin>

to my knowledge the above code helps you in downloading both myAppletjarfile.jar & intendedJarFile.jar in the client computer all you have to do here is that write an action inside the targeted applet

com.applets.MyApplet which can Create an instance of Application related Class by which it would lauch the application.

better part of this approach is that you don't have to manually save intendedJarFile.jar file at a specific location in the client computer the.

wat happens here is client will download the those jar everytime he logs in to the specific site.

2). if you are saving the file at a specific location @ the client side you may have use the same approach above using Applet and you have to lauch the jar using Runtime.getRuntime().exec("java --") or use ProcessBuilder Class.But you need to make sure you have signed the applet & System administrator(@ the client side) has assigned sufficient permissions to do that.

if you are considering an option signing an applet @ the client side...checkout the below link to understand of how to do it.

http://java.sun.com/developer/technicalArticles/Security/Signed/

http://www-personal.umich.edu/~lsiden/tutorials/signed-applet/signed-applet.html

http://mindprod.com/jgloss/signedapplets.html

http://www.jguru.com/faq/view.jsp?EID=11475

3). This one is bit IE specific & where one would write an ActiveX Object using VBScript and then he/she would

run "java --" the same command at the client side and for doing so System Administrator @ the client side should assign sufficient permissions to run the specified ActiveX component and assign the permission to run specific command.

and if you are instrested in doing so...

checkout the below links of how to go about it.

http://techtasks.com/code/viewbookcode/365

http://www.computerperformance.co.uk/ezine/ezine80.htm

http://www.microsoft.com/technet/scriptcenter/guide/sas_wsh_qlcc.mspx?mfr=true

However,@ ethical standpoint i personally don't appriciate any of these solutions,as i'm virtually writing a Spyware out of this.

Hope that might help :)

REGARDS,

RaHuL

RahulSharnaa at 2007-7-21 23:16:30 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...