Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Red X image displayed where the applet should be, applets won't run
Error as described here,

http://www.java.com/en/download/help/redximage.xml


most or nearly all applets from other pages display well in browser

this applet works with the appletviewer.


I got no help on the IRC channel  irc.freenode.net  #java  as they have
the policy  no applets.


I type this in a file

import javax.swing.*;

public class PreviewApplet2 extends JApplet
{

static final long serialVersionUID = -3850477712741615045L;

public void init()
{
JLabel niceLabel = new JLabel("Java is fun!");
ImageIcon dukeIcon = new ImageIcon("duke_waving.gif");
niceLabel.setIcon(dukeIcon);
getContentPane().add(niceLabel);
}
}


and compiles to a class


javac  -Xlint  PreviewApplet2.java


I have the examples from here

http://www-cse.ucsd.edu/users/savitch/  # my book is not listed,

Java:An Introduction to Computer Science and Programming, 2nd Edition

some other examples runs fine, from the command line, on windows
in the appletviewer and in the browser.

But this one gets
Red X image displayed where the applet should be, applets won't run



I use  appletviewer PreviewApplet2.html

and that works  fine.

permissions for the image is

-rwxrwxrwx    duke_waving.gif

a change in permissions to

-rw-r--r--   did not help.


on the  Tools Java  console I can se


Java Plug-in 1.6.0_05
Using JRE version 1.6.0_05 Java HotSpot(TM) Client VM
User home directory = /export/home/morten
----------------------------------------------------
c:   clear console window
f:   finalize objects on finalization queue
g:   garbage collect
h:   display this help message
l:   dump classloader list
m:   print memory usage
o:   trigger logging
p:   reload proxy configuration
q:   hide console
r:   reload policy configuration
s:   dump system and deployment properties
t:   dump thread list
v:   dump thread stack
x:   clear classloader cache
0-5: set trace level to <n>
----------------------------------------------------
java.security.AccessControlException: access denied
(java.io.FilePermission duke_waving.gif read)
at
java.security.AccessControlContext.checkPermission(AccessControlContext.java
:323)
at
java.security.AccessController.checkPermission(AccessController.java:546)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at java.lang.SecurityManager.checkRead(SecurityManager.java:871)
at sun.awt.SunToolkit.getImageFromHash(SunToolkit.java:853)
at sun.awt.SunToolkit.getImage(SunToolkit.java:867)
at javax.swing.ImageIcon.<init>(ImageIcon.java:81)
at javax.swing.ImageIcon.<init>(ImageIcon.java:107)
at PreviewApplet2.init(PreviewApplet2.java:11)
at sun.applet.AppletPanel.run(AppletPanel.java:425)
at java.lang.Thread.run(Thread.java:619)



Java Plug-in 1.6.0_05
Using JRE version 1.6.0_05 Java HotSpot(TM) Client VM
User home directory = /export/home/
----------------------------------------------------
c:   clear console window
f:   finalize objects on finalization queue
g:   garbage collect
h:   display this help message
l:   dump classloader list
m:   print memory usage
o:   trigger logging
p:   reload proxy configuration
q:   hide console
r:   reload policy configuration
s:   dump system and deployment properties
t:   dump thread list
v:   dump thread stack
x:   clear classloader cache
0-5: set trace level to <n>
----------------------------------------------------
java.security.AccessControlException: access denied
(java.io.FilePermission duke_waving.gif read)
at
java.security.AccessControlContext.checkPermission(AccessControlContext.java
:323)
at
java.security.AccessController.checkPermission(AccessController.java:546)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at java.lang.SecurityManager.checkRead(SecurityManager.java:871)
at sun.awt.SunToolkit.getImageFromHash(SunToolkit.java:853)
at sun.awt.SunToolkit.getImage(SunToolkit.java:867)
at javax.swing.ImageIcon.<init>(ImageIcon.java:81)
at javax.swing.ImageIcon.<init>(ImageIcon.java:107)
at PreviewApplet2.init(PreviewApplet2.java:11)
at sun.applet.AppletPanel.run(AppletPanel.java:425)
at java.lang.Thread.run(Thread.java:619)
java.security.AccessControlException: access denied
(java.io.FilePermission duke_waving.gif read)
at
java.security.AccessControlContext.checkPermission(AccessControlContext.java
:323)
at
java.security.AccessController.checkPermission(AccessController.java:546)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at java.lang.SecurityManager.checkRead(SecurityManager.java:871)
at sun.awt.SunToolkit.getImageFromHash(SunToolkit.java:853)
at sun.awt.SunToolkit.getImage(SunToolkit.java:867)
at javax.swing.ImageIcon.<init>(ImageIcon.java:81)
at javax.swing.ImageIcon.<init>(ImageIcon.java:107)
at PreviewApplet2.init(PreviewApplet2.java:11)
at sun.applet.AppletPanel.run(AppletPanel.java:425)
at java.lang.Thread.run(Thread.java:619)
java.security.AccessControlException: access denied
(java.io.FilePermission duke_waving.gif read)
at
java.security.AccessControlContext.checkPermission(AccessControlContext.java
:323)
at
java.security.AccessController.checkPermission(AccessController.java:546)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at java.lang.SecurityManager.checkRead(SecurityManager.java:871)
at sun.awt.SunToolkit.getImageFromHash(SunToolkit.java:853)
at sun.awt.SunToolkit.getImage(SunToolkit.java:867)
at javax.swing.ImageIcon.<init>(ImageIcon.java:81)
at javax.swing.ImageIcon.<init>(ImageIcon.java:107)
at PreviewApplet2.init(PreviewApplet2.java:11)
at sun.applet.AppletPanel.run(AppletPanel.java:425)
at java.lang.Thread.run(Thread.java:619)
java.security.AccessControlException: access denied
(java.io.FilePermission duke_waving.gif read)
at
java.security.AccessControlContext.checkPermission(AccessControlContext.java
:323)
at
java.security.AccessController.checkPermission(AccessController.java:546)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at java.lang.SecurityManager.checkRead(SecurityManager.java:871)
at sun.awt.SunToolkit.getImageFromHash(SunToolkit.java:853)
at sun.awt.SunToolkit.getImage(SunToolkit.java:867)
at javax.swing.ImageIcon.<init>(ImageIcon.java:81)
at javax.swing.ImageIcon.<init>(ImageIcon.java:107)
at PreviewApplet2.init(PreviewApplet2.java:11)
at sun.applet.AppletPanel.run(AppletPanel.java:425)
at java.lang.Thread.run(Thread.java:619)



in the error console I can see the above msg.

I did google for
java.io.FilePermission   duke_waving.gif

and found this explanation



How are you running the applet from the command line? In a browser? In
the appletviewer? Or as an application?

Security settings are different for all three. When applets run in a web
browser, access to the file system is, by default, not permitted. That
is normal.


End of explanation

I look it up from sun

http://java.sun.com/docs/books/tuto...con.html#applet


Loading Images Into Applets

Applets generally load image data from the computer that served up
the applet.


For me it looks like a contradiction.

If I include this line of code in the java file

ImageIcon dukeIcon = new ImageIcon("duke_waving.gif");
niceLabel.setIcon(dukeIcon);

I do expect java to do so and not additionally
append an <IMG SRC="filewithpicture.gif">   to the HTML code.


best regards

Morten



Report this thread to moderator Post Follow-up to this message
Old Post
Morten Gulbrandsen
04-03-08 12:59 AM


Re: Red X image displayed where the applet should be, applets won't run
On Wed, 02 Apr 2008 17:41:50 +0200, Morten Gulbrandsen
<Morten.Gulbrandsen@rwth-Aachen.de> wrote, quoted or indirectly quoted
someone who said :

>Error as described here,

See http://mindprod.com/jgloss/applet.html
for general hints on things to look for.

Turn on your console.  An error message may be sitting there which
will give you a much better clues why it is failing.

http://mindprod.com/jgloss/console.html
--

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

Report this thread to moderator Post Follow-up to this message
Old Post
Roedy Green
04-03-08 12:59 AM


Re: Red X image displayed where the applet should be, applets won't run
In article <65hnpcF2f6bqhU5@mid.dfncis.de>,
Morten Gulbrandsen <Morten.Gulbrandsen@rwth-Aachen.de> wrote:

> Error as described here,
>
> http://www.java.com/en/download/help/redximage.xml
[...]
> java.security.AccessControlException: access denied
> (java.io.FilePermission duke_waving.gif read)
[...]

This is _good_! It means an applet can't load just any old file, but you
should be able to load it from your jar.

John
--
John B. Matthews
trashgod at gmail dot com
home dot woh dot rr dot com slash jbmatthews

Report this thread to moderator Post Follow-up to this message
Old Post
John B. Matthews
04-03-08 12:59 AM


Re: Red X image displayed where the applet should be, applets won't run
Morten Gulbrandsen wrote:

> Error as described here,
>
> http://www.java.com/en/download/help/redximage.xml
>
>
> most or nearly all applets from other pages display well in browser
>
> this applet works with the appletviewer.
>
>
> I got no help on the IRC channel  irc.freenode.net  #java  as they have
> the policy  no applets.
>
>
> I type this in a file
>
> import javax.swing.*;
>
> public class PreviewApplet2 extends JApplet
> {
>
>     static final long serialVersionUID = -3850477712741615045L;
>
>     public void init()
>     {
>         JLabel niceLabel = new JLabel("Java is fun!");
>         ImageIcon dukeIcon = new ImageIcon("duke_waving.gif");
>         niceLabel.setIcon(dukeIcon);
>         getContentPane().add(niceLabel);
>     }
> }
>
>
> and compiles to a class
>
>
>  javac  -Xlint  PreviewApplet2.java
>
>
> I have the examples from here
>
> http://www-cse.ucsd.edu/users/savitch/  # my book is not listed,
>
> Java:An Introduction to Computer Science and Programming, 2nd Edition
>
> some other examples runs fine, from the command line, on windows
> in the appletviewer and in the browser.
>
> But this one gets
> Red X image displayed where the applet should be, applets won't run
>
>
>
> I use  appletviewer PreviewApplet2.html
>
> and that works  fine.
>
> permissions for the image is
>
> -rwxrwxrwx    duke_waving.gif
>
> a change in permissions to
>
> -rw-r--r--   did not help.
>
>
> on the  Tools Java  console I can se
>
>
> Java Plug-in 1.6.0_05
> Using JRE version 1.6.0_05 Java HotSpot(TM) Client VM
> User home directory = /export/home/morten
> ----------------------------------------------------
> c:   clear console window
> f:   finalize objects on finalization queue
> g:   garbage collect
> h:   display this help message
> l:   dump classloader list
> m:   print memory usage
> o:   trigger logging
> p:   reload proxy configuration
> q:   hide console
> r:   reload policy configuration
> s:   dump system and deployment properties
> t:   dump thread list
> v:   dump thread stack
> x:   clear classloader cache
> 0-5: set trace level to <n>
> ----------------------------------------------------
> java.security.AccessControlException: access denied
> (java.io.FilePermission duke_waving.gif read)
>       at
>
java.security.AccessControlContext.checkPermission(AccessControlContext.java:323)
>       at
[snip long stack trace]

>
> in the error console I can see the above msg.
>
> I did google for
> java.io.FilePermission   duke_waving.gif
>
> and found this explanation
>
>
>
> How are you running the applet from the command line? In a browser? In
> the appletviewer? Or as an application?
>
> Security settings are different for all three. When applets run in a web
> browser, access to the file system is, by default, not permitted. That
> is normal.
>
>
> End of explanation
>
> I look it up from sun
>
> [url]http://java.sun.com/docs/books/tutorial/uiswing/components/icon.html#applet[/url
]
>
>
> Loading Images Into Applets
>
>     Applets generally load image data from the computer that served up
> the applet.
>
>
> For me it looks like a contradiction.

No, it's not a contradiction. Applets require a web server, and they load im
ages
from the same web server as they were themselves loaded from (or from within
 a
jar obtained from the same server). If you attempt to load an applet from th
e
local filesystem, as you have done here, then the JVM classloader can load t
he
class you specify, but your class file cannot access the local filesystem
unless you sign the applet. This is for everyone's protection. Otherwise an
applet which you accessed via some random URL would be able to access your
filesystem, which I'm sure you don't want to be allowed.

>
> If I include this line of code in the java file
>
>   ImageIcon dukeIcon = new ImageIcon("duke_waving.gif");
>         niceLabel.setIcon(dukeIcon);
>
> I do expect java to do so

but the applet plugin won't do so, and for a very good reason.

> and not additionally
> append an <IMG SRC="filewithpicture.gif">   to the HTML code.

Huh?

--
Nigel Wade

Report this thread to moderator Post Follow-up to this message
Old Post
Nigel Wade
04-03-08 11:33 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Java Help archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 07:31 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.