aspose file tools*
The moose likes JNLP and Web Start and the fly likes How to run jar file in jsp? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JNLP and Web Start
Bookmark "How to run jar file in jsp?" Watch "How to run jar file in jsp?" New topic
Author

How to run jar file in jsp?

Khushwinder Chahal
Ranch Hand

Joined: Oct 03, 2007
Posts: 128
Hi All,
I want to run a jar file (not an applet) from my web application through a jsp
page.
Right now i m doing like this and its working :



Here i am using absolute path that is what i want to get ride off.

So after this i added this jar file into my classpath (Using netbeans IDE).
And tried to run this file like like:


without hardcoding the path of the jar file.
But this is not working.
I need it urgently.
I will be very helpful if anybody knows any idea.
thanks and Regards,


Khushwinder
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Khushwinder Chahal:

But this is not working.
I need it urgently.


Khushwinder,
Two things...

Please see EaseUp to find out why adding "urgent" to your posts or subject lines can actually slow down or halt responses to your questions altogether (probably not what you intended).

The statement "this is not working" has very little meaning in a web forum.
It would be better to tell us what this jar file is supposed to do.
It may be that this jar file is not suited to a server side web application.
If it has Swing or AWT components, for instance, it would not be possible to run it from a JSP.

Also, tell us what is happening.
Did you check the server logs?
Are there errors there?
Is any type of error message being displayed in the user's browser?

The more you can communicate your needs and describe the situation at hand, the easier it will be for us to help you.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Khushwinder Chahal
Ranch Hand

Joined: Oct 03, 2007
Posts: 128
Thanks for you reply ad suggestions Ben,
I will take care next time.
Regarding my problem,
Its an swing application
so as you said it will not be possible then.
Also i am not getting any err log in server(jboss) log.
One thing i am not understanding that why it works when i give the compelete path of the jar file?
Do you have any idea?
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

If it's working at all, it's only because you are running it from a browser that happens to be on the same machine as the web server.

Even if you get the file path issues straightened out, when a user runs this from their own machine, the Swing app will fire up and be displayed on the server, not their machine. This is most likely not useful to you.

If you want to run Swing or AWT apps on the client's machine, you'll need to decide between applets and Java Web Start (JWS).

We have fora for each of these technologies.
Let me know if you would like this thread moved to one of them.
Khushwinder Chahal
Ranch Hand

Joined: Oct 03, 2007
Posts: 128
Hi Ben,
Please move this thread to JWS
Thanks
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18662
    
    8

Hello Khushwinder, welcome to the JNLP forum. Now that you're here, could you please restate your question? It's been through a lot of answering and I don't see what the remaining question is. And what it has to do with JNLP either.
Khushwinder Chahal
Ranch Hand

Joined: Oct 03, 2007
Posts: 128
Hi Paul,

I want to run a swings jar file from my web application through a jsp
page.
Is it possible in JNLP?
If you have any idea please advise me.

Thanks
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18662
    
    8

Do you want to run that on the client or on the server? (Running things on the server usually doesn't make any sense, but you never know what kinds of things people think they want.)

You said JSP... so presumably there's some sort of dynamic content? Does this dynamic content have anything to do with the Swing (not "swings") application? You can certainly download a jar file and run it via JNLP, it's just that your reference to JSP complicates the issue.

Perhaps you could explain the background behind this idea? It's possible you should be doing something entirely different.
Khushwinder Chahal
Ranch Hand

Joined: Oct 03, 2007
Posts: 128
Hi Paul,
I am going to explain everything which i have done and which still need to be done. In my web based application i want to call a jar file which is consist of swings components. Normally we can only invoke applet applications in a web based application but not the swings or awt. So after this Ben suggested me to go for JWS. while studying about JWS i found that it is possible to invoke a jar file(swings) in web based application by using JWS.
So i am not going for this. I have created keystore file after that i converted my jar file to signed jar file and then now i want to integrate this with my web based application.
I am using JBoss server.
I have a questions here.
Where should i place my jar file and jnlp file inside jboss server directory so that my web application's jsp page can access it?
Please advice me if i am going in right path or not.
I have doubts whether i am going in right path or not..
Please enlighten my path
Thanks
Khushwinder Chahal
Ranch Hand

Joined: Oct 03, 2007
Posts: 128
Hi Paul,
I have successfully implemented jnlp on my web based application.
Now my web page is able to call swings jar file
But i am getting one problem here, when i try to access that application
from some other system by giving url like :

http://ipaddressofmysystem:8080/dash-board

and try to run the same application from jsp page, it starts the jnlp service
but after some time it gives the exception like :

java.security.AccessControlException: access denied (java.io.FilePermission Server.log write)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkWrite(Unknown Source)
at java.io.FileOutputStream.<init>(Unknown Source)
at java.io.FileOutputStream.<init>(Unknown Source)
at BabylonServer.<init>(BabylonServer.java:114)
at BabylonServer.main(BabylonServer.java:748)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.javaws.Launcher.executeApplication(Unknown Source)
at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
at com.sun.javaws.Launcher.doLaunchApp(Unknown Source)
at com.sun.javaws.Launcher.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)


What could be the problem here i am not getting.
Is there any problem with creating of signed jar file or there is some other problem.
Please if you have any idea suggest me.
Thankz\s
Khushwinder Chahal
Ranch Hand

Joined: Oct 03, 2007
Posts: 128
Hi Paul,
I have figured out the problem now
The problem is in java.policy file in jre.
I need to add the following line to get the required permissions:

permission java.security.AllPermission;

.
But how can i send this line with my jar file?
Do you have any idea ?
Thanks
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18662
    
    8

You don't "send that line" with your jar file. If your program is doing insecure things (such as accessing the client's file system), then you have to sign the jar file. The process for doing that is described in the JNLP tutorial (and it's far too long to repeat here).

Note that if you actually changed the policy file in the client's JRE, that would allow any Java program or applet that was ever run in that JRE to do anything it liked to the system. Not just your program, any program. That would be a serious security exposure, so don't do it.
Khushwinder Chahal
Ranch Hand

Joined: Oct 03, 2007
Posts: 128
Hi Paul
Thanks a lot for your reply.
But i am already signing that jar file with the following 2 cmds :

1) Is for generating the keystore on my system.

keytool -genkey -alias sona -keypass 121212 -keystore store

2) Is for signing the jar file.

jarsigner -keystore store img.jar sona

Is there anything other i need to set for signing my jar file?
Regards,
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18662
    
    8

I don't know (haven't got that far myself). Is that what it said to do in some documentation you read? (Post a link to it if so.)

And (silly question) are you actually using the signed version of the jar file and not the original version?
Khushwinder Chahal
Ranch Hand

Joined: Oct 03, 2007
Posts: 128
Hi Paul

I am using this link for signing the jar file :

http://java.sun.com/docs/books/tutorial/deployment/jar/signing.html

And i have double checked that i am using the signed jar file
Thanks for valuable suggestions
 
 
subject: How to run jar file in jsp?