Signed Applet can't read an image file??

Hi my dear java folks,
I've written a simple applet and self-signed it in order to have access
to local machine's files.
The applet as you see needs to read an image file (arrow.gif).
The applet is:
import.....
public class MyApplet extends JApplet{
JButton button1=new JButton("Save");
JButton button2=new JButton(new ImageIcon("arrow.gif"));
public void init(){
button1.setBounds(10,70,80,20);
button2.setBounds(10,100,80,20);
getContentPane().setLayout(null);
getContentPane().add(button1);
getContentPane().add(button2);
The java.policy file is:
keystore ".//myworkingstore.store";
grant codeBase "http://fin2000/htdocs/MyApplet.class" {
permission java.io.FilePermission "<<ALL FILES>>","read";
permission java.io.AllPermission;
grant codeBase "." signedBy "MyName" {
permission java.io.FilePermission "${user.home}/*.*","read,write";
permission java.io.FilePermission "<<ALL FILES>>","read";
permission java.io.AllPermission;
The java.security file is on the server
(on my server I have Oracle8.1/Apache installed):
policy.url.1=file:d:/oracle/ora81/apache/apache/htdocs/java.policy;
My problem is when I run my applet through a html file
"http://myServerName/test.html" in my browser, the applet
runs correctly except it's button2 (the iconized button), the
button comes without it's ImageIcon on it.
I receive no errors, no messages and no signs of error
I am completely confused!
Need Urgent Help
Thank you , Jamanir

Hi,
this has nothing to do with a security problem.
Change you code as follow:
  JButton button2 = new JButton(new ImageIcon(getClass().getResource("arrow.gif")) ;Pack arrow.gif in the same directory/package as MyApplet.class in the jar file and It should solve your problem...
The problem is that when you write new ImageIcon("arrow.gif"), it works locally as a standalone application, because "arrow.gif" is mapped to the current directory where you application is started from. This has no meaning when you works online with an applet. That's the reason why your graphic was not found.
getClass().getResource("arrow.gif") returns an URL pointing to a file "arrow.gif" located at the same location as the class. This always works either locally or online, other packed in a Jar file, or unpacked.
Yannick

Similar Messages

  • Signed applet can't read image file..

    Hello
    My English ability is very poor.. sorry
    I make a signed applet
    and I open Internet Exploere
    I connect to my web page
    when I connect to my web page
    my signed applet upload "c:\blahbalh...\image.gif" automatically
    but It's not work
    java.security.AccessControlException: access denied (java.io.FilePermission C:\DOCUME~1\krict\LOCALS~1\Temp\Hnc\BinData\EMB00000cac2143.jpg read)
         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.checkRead(Unknown Source)
         at java.io.FileInputStream.<init>(Unknown Source)
         at java.io.FileInputStream.<init>(Unknown Source)
         at EchoApplet.onSendData(EchoApplet.java:61)
         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 sun.plugin.javascript.invoke.JSInvoke.invoke(Unknown Source)
         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 sun.plugin.javascript.JSClassLoader.invoke(Unknown Source)
         at sun.plugin.com.MethodDispatcher.invoke(Unknown Source)
         at sun.plugin.com.DispatchImpl.invokeImpl(Unknown Source)
         at sun.plugin.com.DispatchImpl$1.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         at sun.plugin.com.DispatchImpl.invoke(Unknown Source)
    signed applet can't not read file..
    how can I solve my problem?

    Trace please.
    http://forum.java.sun.com/thread.jspa?threadID=656028
    Maybe some relevant code
    Signing applets:
    http://forum.java.sun.com/thread.jsp?forum=63&thread=524815
    second post and reply 18 for the java class file using doprivileged

  • How can I read a image file through URI?

    I have a image file store in my computer's Image directory on drive E. I name the pathname as:
    file:////MyComputerName/e:/image/
    the image filename is MyImage.JPG
    so I create a ImageIcon use:
    String uri  = "file:///MyComputerName/e:/image/";
    String imagefilename = "MyImage.JPG";
    ImageIcon ii = new ImageIcon( uri+imagefilename);
    Image myimage = ii.getImage();but I can not get the image.
    Does anyone know what's wrong?
    Thank you

    Read the documentation for ImageIcon(String path) -- the String is a file path,
    not a URL. If you want to pass a URL to ImageIcon, use ImageIcon(URL url).
    So, either of the following works:
    URL url = new URL("file:///e:/image/MyImage.JPG");
    ImageIcon imageIcon1 = new ImageIcon(url);
    String path = "e:/image/MyImage.JPG";
    ImageIcon imageIcon2 = new ImageIcon(path);In case you even need it, to convert a file into a URL, you can write:
    URL url = file.toURI().toURL();And finally, you may want to check out BufferedImage and ImageIO.
    You can read in a BufferedImage in one line:
    BufferedImage image = ImageIO.read(file_or_url_etc);and a BufferedImage offers may advantages over a plain old image.

  • Applet can't read local file on web server, security issue!

    There is any way to read/write files of web server through the applet except the Signed Applet.
    If any idea the reply me soon.
    Thanks in advance

    Applets are downloaded from web servers and execute on the client machine.
    Therefore they have no access to the web server file system, signed or not.
    They could have access to the client file system (the machine where they run),
    but for security reasons only signed applets have this privilege.
    So to answer your question, you sign if you want to access client files.
    To access web server files, you don't need to sign the applet, but you need
    to provide some method of accessing files remotely, for instance:
    - Files published for the web can be read using HTTP
    - Files can be read or writen with the help of an FTP server on the same machine as the web server
    - A servlet running on the HTTP server can collaborate with your applet to exchange files

  • Applet can't read files

    Hello!
    I have developped ticker news applet
    A previous version was working fine. The applet had a thread. I used the pain method to display texte and logos. It took the news a logo from the applets parameters and printing them one by one on the html page.
    Now the problem was that I had to refresh the whole applet to change the news. That's why I developped another version that extract the news and links to images from 2 separated files. One file contains the news texts, the other the logos. Each one is uploads in a vector. The applet is working fine in textpad but not in the browser.
    The error I get in the console is array out of bound. The vector seems to be empty. My diagnotic is that the applet can't read the file. Am I right? Any solutions
    Here's the applet call and its parameters.
    mess.txt contains the news
    newsimage.txt the links to the images. Actually the images are in the home directory.
    <applet code="aTicker.class" archive="aTicker.jar"
              hspace=0 vspace=0 border=0 align="left" width=640 height=38 MAYSCRIPT>
         <param name="newsfile" value="mess.txt">
         <param name="imagefile" value="newsimage.txt">
         <param name="pas" value="650">
         <param name="cSep" value=";">
         <param name="speed" value="4">
         <param name="delay" value="30">
         <param name="xSpace" value="50">
         <param name="prepicdelay" value="1000">
         <param name="picdelay" value="2000">
         <param name="scrollingdelay" value="100">
         <param name="local" value="true">
         <param name="Font2" value="Verdana, 40, 0, 16776960">
         <param name="Font1" value="Serif , 40, 1, 16776960 ">
    </applet>
    I found this link but it didn't help me
    http://java.sun.com/sfaq/#read
    [email protected]

    All that can be said from the info you provide is that an array is being accessed with an invalid index value. Your guess may (or may not) be correct.
    Sprinkle some System.out.println statements through the code and do some diagnostics. The println's will output their data in the Sun Java Console.

  • How can I upload a (image) file through an applet ?

    How can I upload a (image) file through an applet ?

    have a look at http://www.haller-systemservice.net/jupload/
    i'm using Apache Jakarta HTTPClient to create a new HTTP connection to the webserver and sending a new POST request, which holds the image file. (So it's RFC1867 conform)
    there is also an open source implementation of such an applet on sourceforge. it's also called JUpload, but i think it's not maintained any more.

  • How can i upload a image file to server by using jsp or servlet.

    Hi,
    I m gurumoorthy. how can i upload a image file to server by using jsp or servlet without using third party API. pls anyone send me atleast outline of the source code.
    Pls send me anyone.
    Regards,
    Gurumoorthy.

    I'm not an applet programmer so I can't give you much advice there.
    If you want to stream the file from the server before it's entirely uploaded, then I don't believe you can treat it like a normal file. If you're just wanting to throw it up there and then listen to it, then you can treat it like a normal file.
    But again, I'm not entirely certain. You might be able to stream the start of the file from the server while you're still uploading the end of it, but it probably depends on what method you're using to do the transfer.

  • Can I insert the image file into PDF file  in Adobe X Standard ?

    can I insert the image file into PDF file in Adobe X Standard ?

    http://matt.coneybeare.me/how-to-make-an-html-signature-in-apple-mail-for-maveri cks-os-x-10-dot-9/

  • Reading a image file and printing it by a Servlet

    In a IMAGE TAG of HTML file i am calling servlets what will write a image to the browser.
    <IMG SRC="http://localhost/WriteImage" width="50" height="100">
    The Servlet WriteImage has to read a image from a location(it could be gif,jpeg,png or another format of images ) and it has to write to the above image tag.
    Anyone can u help me out how i can do this...
    I tried out with javax.imageio package but couldn't get it.
    Thank Q
    Vijay

    Your WriteImage servlet needs to read the image file in from wherever it is (hard drive, database, whatever), then write it back out to the browser. To do that, first use the HTTPServletResponse object to send the appropriate headers, then call the getOutputStream() method to get an output stream to write the data to. This data will be sent to the browser which, if you've set the headers correctly, will display it as an image.
    It's been a long time since I did this (we abandoned storing images in databases quite a long time ago), so I can't be more specific than that, but hopefully that'll be enough to get you going. If you run into any problems, reply and I'll see if I can help further.

  • Reading Tiff image files

    Can anybody help me to find out any freeware tools or api to read an image file in tiff format.
    The content of tiff file is all text and I have to convert all tiff files into .txt file.
    Any help would be appreciated.
    -R

    Try JAI. A good place to learn how to read files is at http://java.sun.com/j2se/1.4.2/docs/guide/imageio/spec/title.fm.html

  • I have the latest downloadable version of LR5.  It crashed while it was createing 1:1 previews during an import. After a Win7(64) restart, it shows a message that LR needs to quit because it can't read the preview files and it will try to fix it the next

    I have the latest downloadable version of LR5.  It crashed while it was createing 1:1 previews during an import. After a Win7(64) restart, it shows a message that LR needs to quit because it can't read the preview files and it will try to fix it the next time is launches.  I get the same message the next and every subsequent time it launches so I can't launch LR at all now.
    I get that the preview file got corrupted somehow.  Is there some way to fix this problem without building a new catalog?

    Use Windows Explorer to open the folder containing your catalog. You will see a folder with the extension .lrdata. You need to delete that folder and then start Lightroom again. Lightroom will generate a new previews folder.

  • How can one  read a Excel File and Upload into Table using Pl/SQL Code.

    How can one read a Excel File and Upload into Table using Pl/SQL Code.
    1. Excel File is on My PC.
    2. And I want to write a Stored Procedure or Package to do that.
    3. DataBase is on Other Server. Client-Server Environment.
    4. I am Using Toad or PlSql developer tool.

    If you would like to create a package/procedure in order to solve this problem consider using the UTL_FILE in built package, here are a few steps to get you going:
    1. Get your DBA to create directory object in oracle using the following command:
    create directory TEST_DIR as ‘directory_path’;
    Note: This directory is on the server.
    2. Grant read,write on directory directory_object_name to username;
    You can find out the directory_object_name value from dba_directories view if you are using the system user account.
    3. Logon as the user as mentioned above.
    Sample code read plain text file code, you can modify this code to suit your need (i.e. read a csv file)
    function getData(p_filename in varchar2,
    p_filepath in varchar2
    ) RETURN VARCHAR2 is
    input_file utl_file.file_type;
    --declare a buffer to read text data
    input_buffer varchar2(4000);
    begin
    --using the UTL_FILE in built package
    input_file := utl_file.fopen(p_filepath, p_filename, 'R');
    utl_file.get_line(input_file, input_buffer);
    --debug
    --dbms_output.put_line(input_buffer);
    utl_file.fclose(input_file);
    --return data
    return input_buffer;
    end;
    Hope this helps.

  • How can I read the bootstrap files and extract the fragment-URLs and fragment-numbers in plain text?

    How can I read the bootstrap files of any HDS Live stream and extract the fragment-URLs and fragment-numbers in plain text?
    Could it be that it is some kind of compressed format in the bootstrap? Can I uncompress it wirh  f4fpackager.exe? Could not find any download for f4fpackager.exe. I would prefere less code to do so. Is there something in Java of JavaScript, that can extract the fragment-numbers?
    Thank you!

    Doesn't sound too hard to me. Your class User (the convention says to capitalize class names) will have an ArrayList or Vector in it to represent the queue, and a method to store a Packet object into the List. An array or ArrayList or Vector will hold the 10 user objects. You will find the right user object from packet.user_id and call the method.
    Please try to write some code yourself. You won't learn anything from having someone else write it for you. Look at sample code using ArrayList and Vector, there's plenty out there. Post in the forum again if your code turns out not to behave.

  • How can i read local excel file into internal table in webdynpro for abap a

    Could someone tell me how How can i read local excel file into an internal table in webdynpro for abap application.
    thank u for your reply

    Deep,
    File manuplations...............................
    1. At the presentation level:
    ->GUI_UPLOAD
    ->GUI_DOWNLOAD
    ->CL_GUI_FRONTEND
    2. At the application server level:
    ->OPEN DATASET : open a file in the application server for reading or writing.
    ->READ DATASET : used to read from a file on the application server that has been opened for reading
    -> TRANSFER DATASET : writing data to a file.
    -> CLOSE DATASET : closes the file
    -> DELETE DATASET : delete file
    If file is on the local PC,use the function module GUI_UPLOAD to upload it into an internal table by passing the given parameters......
    call function 'GUI_UPLOAD'
    exporting
    filename = p_file
    filetype = 'ASC'
    has_field_separator = '#'
    tables
    data_tab = t_data
    p_file : excel file path.
    t_data : internal table
    <b>reward points if useful.</b>
    regards,
    Vinod Samuel.

  • How can i display a image file which is placed in the applications server

    Hi all,
    Can any one help me how can I display a image file which is present in the application server.
    With regards,
    M.Ramana Murthy

    hi,
    *& Form TOP_OF_PAGE
    * text
    FORM F_TOP_OF_PAGE.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
    IT_LIST_COMMENTARY = IT_LISTHEADER
    i_logo = Logo name
    * I_END_OF_LIST_GRID =
    ENDFORM. "TOP_OF_PAGE
    rgds
    Anver

Maybe you are looking for

  • SQL Server 2008 Reporting Services HTTP 500 error

    Hi Everyone, I recently tried changing authentication mode in RSReportServer.config, I changed from RSWindowsBasic to RSWindowsNegotiate. After restarting the services, I tried to access the Reports page (which worked before my change), but I was una

  • [Error] Notification icons are there, but don't appear! GNOME 3

    Hey mates. So... if you read the title you will not need much more explanation. See for yourself! Click on the thumbnails to enlarge the image: So... what do you think? What I've done wrong?

  • DBMS_XMLDOM... help needed

    hi all, I have two domdocuments. I need to append the first document to the child of the second domdocuments domnode. while trying this i am getting the error saying that the nodes are from dfferent documents. How do I do this using dbms_xmldom. i tr

  • "REP-50125: rwbuilder.conf:java.lang.NullPointerException

    when i try to to launch Reports Builder 11g in Windows 7 (32-bit or 64-bit), the Reports Builder is not launching. However, the icon for it appears in the Windows taskbar. Opening it presents the error: "REP-50125: rwbuilder.conf:java.lang.NullPointe

  • E72- stop the "select connection" tab popping up

    This is randomly popping up all the time. Can I just set it to access the wireless network when it's available and needed (but not all the time) and just use contract internet the rest of the time? The pop-up is getting irritating.