473,378 Members | 1,527 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Directory problem

18
This is not a reply to Luron31 ... but for some reason I cannot create a new thread. So excuse me for temporarily highjacking the thread.

I am using NetBeans and trying to write an image (.png) to a Panel. In order to get the image file, I've had to specify the entire path of the resource file, i.e.

image = Toolkit.getDefaultToolkit().getImage("C:/Documents and Settings/Krall/My Documents/NetBeansProjects/Qubic/src/qubic/resources/lightgroup.png");

...
g.drawImage (image,0,0,this);

When I google use of getImage() ... all the examples use a *relative* path name -- e.g.

getImage ("lightgroup.png");

My question is: what directory path does the system use by default to locate the image files? Is there a way to programmatically obtain this path ? It doesn't seem to have anything to do with CLASSPATH ... but as you can see above, I was able to locate and use an image file (lightgroup.png) that was already a resource stored in my project hierarchy.

Of course I could store all the image files I want to use in the exact same place and I could use a full fixed file path every time I do getImage() ... but I'm trying to understand how Java/NetBeans works in this regard.

Thanks
Jul 9 '09 #1
2 1727
JosAH
11,448 Expert 8TB
Hi, I moved your post to its own thread; to start a new thread navigate to

topics>Java>

There are two choices there: 'answers' and 'insights'. The first choice brings you to the forum, the second one shows you a bunch of articles, written for your information. You can start your thread in the first choice (there's a button near the top of that page).

kind regards,

Jos
Jul 9 '09 #2
JosAH
11,448 Expert 8TB
Better use the static method read(InputStream ...) from the ImageIO class and obtain the InputStream from the getResourceAsStream(String ...) from the Class class. That way images don't even have to be stored as files but can be stored in jar files etc.

kind regards,

Jos
Jul 9 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: o'seally | last post by:
solaris/linux admins/rookie_developers that battle with this error are probably all frustrated when it happens. i bet you're also somehow frustrated by this seemingly unsolvable error :-) ...take...
11
by: Etienne Charland | last post by:
Hi, I have a solution containing 6 C# projects; 1 WinForms project and 5 class libraries. I didn't have any problems until recently. I added a new project containing reports. I am using...
1
by: Andrew | last post by:
Hey all, Working on revamping our Intranet here and making use of the LDPA, Active Directory, Directory Services, etc. that .Net provides. I am still fairly new on this subject, so the problem...
3
by: James Coleman | last post by:
Hello, The following error is appearing when attempting to create a directory using the availale system.io methods: System.IO.DirectoryNotFoundException: Could not find a part of the path...
8
by: nick | last post by:
I have a problem and I've been using a cheezy work around and was wondering if anyone else out there has a better solution. The problem: Let's say I have a web application appA. Locally, I set...
2
by: Danny Miller | last post by:
Hi there, I'm facing a problem that is driving me nuts. The scenario is as follows: 1) Create an empty directory structure e.g. C:\Dev1\TestWebApp 2) Map a virtual directory e.g. TestWebApp...
9
by: Benny Ng | last post by:
Hi,all, How to let the sub-directory to avoid the authentication control from Root's webconfig? I heard that we can add a new web.config to the sub-directory. And then we can slove the problem....
28
by: Peter Oliphant | last post by:
I have written a program using MS VS VC++ 2005 Express, /cli pure. Upon compiling it it works fine in the GUI development environment. It also works fine as a Debug stand-alone. ut I had an odd...
0
by: Matt MacDonald | last post by:
Hi all, I'm having a really frustrating problem. I have a web application that needs to modify the directory structure of the underlying files. The problem I'm having is that after the system...
13
by: lawpoop | last post by:
Hello all - I have a two part question. First of all, I have a website under /home/user/www/. The index.php and all the other website pages are under /home/user/www/. For functions that are...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.