I am devoloping an application with swing as front end and tomcat as web server.Now I am using jnlp to start my application. My jar have several image files. But when running without using an image file in jar and commenting the code section using image, it works fine. When image is used the following error shows by the webstart.
An error occurred while launching/running the application.
Title: Notepad Demo
Vendor: The Java(tm) Tutorial: Sun Microsystems, Inc.
Category: Security Error
I tried putting the image file working directory and in a seperate folder named "images" in the jar file. Now I tries to run my application from the jar directly avoiding the web server to find whats the error.
Using the command "file:///C:/jnlp/helloworld.jnlp"
and my jnlp looks like this
---------------------------------
<?xml version="1.0" encoding="utf-8"?>
<!-- JNLP File for Notepad -->
How are you trying to access the file? Using a File with "images//Curveline.jpg" is not going to work, since that will look on the local file system (and consequently throw a security exception). you'll need to use something like " getClass().getResourceAsStream("/images/Curveline.jpg") ".
codebase="file:///c:/jnlp/""
Don't use the "file:" protocol for this; it's not going to work once you run the application off a web server.
Don't use the "file:" protocol for this; it's not going to work once you run the application off a web server.
Thanks for your support Mr. Dittmer., I used the the getClass().getResourceAsStream(path); as you said but I still have some problem. I gets Exception when I run my application in JNLP, but it works smoothly in ordinary run using "java" command.
I think it is of some permission error.The Error I got looks like;
-----------------------------------------------------------------------
"An error occurred while launching/running the application.
Title: Curveline BIsolution
Vendor: The Java(tm) Tutorial: Sun Microsystems, Inc.
Category: Security Error
Unsigned application requesting unrestricted access to system
Unsigned resource: file:/c:/BISolution/build/jar/BISolution.jar
------------------------------------------------------------------------
The Exception is
----------------------------------------------------------------------
JNLPException[category: Security Error : Exception: null : LaunchDesc:
<jnlp spec="1.0+" codebase="file:/c:/BISolution/" href="file:/c:/BISolution/bisolution.jnlp">
<information>
<title>Curveline BIsolution</title>
<vendor>The Java(tm) Tutorial: Sun Microsystems, Inc.</vendor>
<homepage href="null"/>
<description>Notepad Demo</description>
<description kind="short">ClickMeApp uses 3 custom classes plus several standard ones</description>
<icon href="file:/c:/BISolution/default" kind="default"/>
<offline-allowed/>
</information>
<security>
<all-permissions/>
</security>
<resources>
<property name="jnlp.publish-url" value="$$context/publish"/>
<jar href="file:/c:/BISolution/build/jar/BISolution.jar" download="eager" main="true"/>
<j2se href="http://java.sun.com/products/autodl/j2se" version="1.5+"/>
</resources>
<application-desc main-class="com.curvature.presentation.CurveLineFrame"/>
</jnlp> ]
at com.sun.javaws.LaunchDownload.checkSignedResourcesHelper(Unknown Source)
at com.sun.javaws.LaunchDownload.checkSignedResources(Unknown Source)
at com.sun.javaws.Launcher.continueLaunch(Unknown Source)
at com.sun.javaws.Launcher.handleApplicationDesc(Unknown Source)
at com.sun.javaws.Launcher.handleLaunchFile(Unknown Source)
at com.sun.javaws.Launcher.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)