Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Loading image from file.

Posted on 1998-03-17
7
Medium Priority
?
229 Views
Last Modified: 2010-04-16
I've been loading image into memory using getImage(URL, String) which must be run from an applet. I now want to perform this code elsewhere, meaning I can use URL bit, besides I want to access my local directory. What methods exist to perform this operation.

Thanks

Jonc
0
Comment
Question by:Jonc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 16

Expert Comment

by:imladris
ID: 1233623
An applet can only access the server from which it was loaded.
If it was loaded from across the wire, you can only access that URL. If it loaded from the local machine, it can access a file on the local machine, but it can then not access a URL pointing to another machine.
0
 

Author Comment

by:Jonc
ID: 1233624
I thought it I signed the file with a digital signature, I could access the local files. Anyway, assuming I can't access another machine, how do I load a file from the local machine from a method that does not extend Applet as getImage is from Applet.

i.e. I have a class, extends applet, then I have a class that extends frame and wants to display the image. I really want the user to select using the FileDialog, which is what I had until I moved the code from the class extending Applet.
0
 
LVL 6

Expert Comment

by:gadio
ID: 1233625
 You can get permission to do that through digital signature in netscape and in the explorer. In the explorer you can also give an applet permissions to do almost anything . to do that  perform the following:  use view -> internet options -> security tab -> trusted site zone -> add sites -> (write the servers address) -> Add -> OK -> set Custom security level -> Settings... -> scroll to Java permissions ->   Check the "Custom" Checkbox -> Click the "Java Custom Settings..." -> Select the "Edit Permission" tab. -> Under "Run Unsigned Content" Check the "Enable" Checkbox -> Click "OK" -> Click "OK" -> Click Apply -> Click "OK".
 
   Once you have a trusted applet, all you have to do is use a URL the same way you did before but direct it to the local disk (like   new String urlname("file:///images/king.jpg");  ). Use this new URL instead of the old one and load the image the same way.

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Jonc
ID: 1233626
Excellent, just what I wanted, how do I change this to grade your response qadio?

Do I reopen and you type in something irrelevant and I grade you on that?
0
 
LVL 6

Expert Comment

by:gadio
ID: 1233627
Reject the previously given answer, and then I'll write an answer here.

0
 
LVL 16

Expert Comment

by:imladris
ID: 1233628
Thank you, learned something here.

It is perhaps worth noting consequences though. If you aren't the only user of the code, then anyone else who wants to use it will have to have the relevant stuff on their drive and, more importantly, bypass their security as indicated above. This, of course, opens them up to malicious applets.

0
 
LVL 6

Accepted Solution

by:
gadio earned 200 total points
ID: 1233629
 imladris: yes, the person using that method should have all the relevant stuff on his machine, or this stuff should be downloaded to his machine by this applet. Anyway, this is not an applet working model anymore, its more of an application working model. The security is a problem, but opening the site as I indicated in my answer (I'll quote it again) allows only to the applets coming from that site to access restricted resources, so the problem is limited if you consider that site "safe".


The answer again:
-----------------
  You can get permission to do that through digital signature in netscape and in the explorer. In the explorer you can also give an applet permissions to do almost anything . to do that  perform the following:  use view -> internet options -> security tab -> trusted site zone -> add sites -> (write the servers address) -> Add -> OK -> set Custom security level -> Settings... -> scroll to Java permissions ->   Check the "Custom" Checkbox -> Click the "Java Custom Settings..." -> Select the "Edit Permission" tab. -> Under "Run Unsigned Content" Check the "Enable" Checkbox -> Click "OK" -> Click "OK" -> Click Apply -> Click "OK".
     
   Once you have a trusted applet, all you have to do is use a URL the same way you did before but direct it to the local disk (like    new String urlname("file:///images/king.jpg");  ). Use this new URL instead of the old one and load the image the same way.

0

Featured Post

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question