Review your favorite Linux distribution.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 07-17-2009, 08:33 AM   #1
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, 10:28 AM   #2
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.

Put a debug statement in your 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

Here's code for reading a local file from a Java applet:

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

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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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-14-2009 12:25 AM
Image Path reference in Linux (Absolute path) javabuddy Linux - General 7 06-05-2006 08:45 AM
relative to absolute path vishalbutte Programming 4 01-14-2006 04:17 PM
relative/absolute paths in Java djgerbavore Programming 2 10-26-2004 09: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 07:28 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:35 PM.

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