This week's giveaway is in the Java in General forum.
We're giving away four copies of Java Challengers and have Rafael del Nero on-line!
See this thread for details.
Win a copy of Java Challengers this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

Image file in cannopt access-getting error

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

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

access denied (java.io.FilePermission images//Curveline.jpg read)


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 -->

<jnlp spec="1.0+"
codebase="file:///c:/jnlp/""
href="helloworld.jnlp">
<information>
<title>Notepad Demo</title>
<vendor>The Java(tm) Tutorial: Sun Microsystems, Inc.</vendor>
<description>Notepad Demo</description>
<description kind="short">ClickMeApp uses 3 custom classes plus several
standard ones</description>
<offline-allowed/>
</information>
<resources>
<jar href="helloworld.jar"/>
<j2se version="1.5+"
href="http://java.sun.com/products/autodl/j2se"/>
</resources>
<application-desc
main-class="CurveLineFrame"
width = "900"
height = "600"
/>
</jnlp>
-----------------------------------------

Please help me

Regaards..
Shanavas
 
Marshal
Posts: 26536
81
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"shanavas ct", please check your private messages regarding an important administrative matter.

Thank you.
 
Rancher
Posts: 43024
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
shanavas ct
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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)

---------------------------------------------------------------------

My JNLP file is given below please suggest that some thing I have to add some more entries make it work.
Or in jave code

Please help me........

Thank You,
Shanavas
 
Ulf Dittmer
Rancher
Posts: 43024
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:Don't use the "file:" protocol for this

 
How do they get the deer to cross at the signs? Or to read this tiny ad?
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic