LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 04-11-2006, 10:16 PM   #1
linuxmandrake
Member
 
Registered: Sep 2004
Distribution: debian sarge 64bit (AMD)
Posts: 709

Rep: Reputation: 30
getting current directory where classes are stored


How do I obtain the directory where the classes are stored so I can put my images together with the classes.

tried ImageIcon image = new ImageIcon("Star-Trek-full.gif"); but it doesn't work even though it's in the same directory as the classes. And preferrably os independent. Using java
 
Old 04-11-2006, 11:01 PM   #2
mrcheeks
Senior Member
 
Registered: Mar 2004
Location: far enough
Distribution: OS X 10.6.7
Posts: 1,690

Rep: Reputation: 52
You put your images in your classes directory and you do the following :
Code:
ImageIcon icon = new ImageIcon(getClass().getResource("image.gif"));
 
Old 04-14-2006, 06:11 AM   #3
linuxmandrake
Member
 
Registered: Sep 2004
Distribution: debian sarge 64bit (AMD)
Posts: 709

Original Poster
Rep: Reputation: 30
cool but in the end i decided to put it in the root directory which means it will be just
ImageIcon icon = new ImageIcon("image.gif");
 
  


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
find in current directory ramanadyv Linux - Newbie 3 03-28-2006 10:12 PM
how do you determine the max number files can be stored in a single directory on the genux33 Linux - General 2 12-13-2005 05:40 PM
OOP (PHP) classes and extended classes ldp Programming 3 03-05-2005 11:45 AM
couldn't get to current directory Paxmaster Linux - Newbie 0 11-22-2004 12:37 PM
list only files in current directory xscousr Programming 8 09-22-2003 07:35 AM

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

All times are GMT -5. The time now is 08:00 AM.

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