LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-17-2009, 07:33 AM   #1
amolgupta
Member
 
Registered: Feb 2005
Location: agra,india
Distribution: FC2
Posts: 158

Rep: Reputation: 30
java applet not loading image with relative path but loads image with absolute path


java applet not loading image with relative path(e.g. images/1.jpg) but loads image with absolute path(i.e. from /root/user/images/1.jpg) . This is a problem when i want to host the applet on web server
 
Old 07-17-2009, 09:28 AM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
A couple of problems/questions here:

1. If this is really an "applet"...
... then it's executing on the *client's* PC...
... and the client won't necessarily have an "images/" directory.

2. You're assuming that the Java program's working directory is "/root/user". This *isn't* necessarily true.

SUGGESTION:
Put a debug statement in your code:
Code:
String dir = System.getProperty("user.dir");
Once you know what the *actual* directory is, see if relative paths now work (e.g. "../images/1.jpg" instead of "images/1.jpg).

'Hope that helps .. PSM

PS:
Here's code for reading a local file from a Java applet:
http://www.captain.at/programming/java/

Last edited by paulsm4; 07-17-2009 at 09:30 AM.
 
Old 07-20-2009, 01:58 PM   #3
amolgupta
Member
 
Registered: Feb 2005
Location: agra,india
Distribution: FC2
Posts: 158

Original Poster
Rep: Reputation: 30
thanks ,issue resolved , getResource worked out
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
set up java_home path in /home/user/.bashrc but use path in /usr/lib/java vitalstrike82 Slackware 4 01-13-2009 11:25 PM
Image Path reference in Linux (Absolute path) javabuddy Linux - General 7 06-05-2006 07:45 AM
relative to absolute path vishalbutte Programming 4 01-14-2006 03:17 PM
relative/absolute paths in Java djgerbavore Programming 2 10-26-2004 08:01 PM
Loading Suse Linux 9.0 loads to the point of ramdisk:Compressed image found at block0 todd1234 Linux - Newbie 7 02-24-2004 06:28 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:23 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration