?
Solved

Loading image from file.

Posted on 1998-03-17
7
Medium Priority
?
223 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

Industry Leaders: 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!

Question has a verified solution.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses
Course of the Month8 days, 1 hour left to enroll

765 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