• Post Reply Bookmark Topic Watch Topic
  • New Topic

Eclipse vs terminal  RSS feed

 
Stuie Clarky
Ranch Hand
Posts: 98
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all, got a question that I'm just drawing a blank on currently.

I have a simple program that animates some images on a frame. Nice and straightforward, works a treat when I compile and run with javac/java. However I have moved the class and image files into Eclipse. All in one directory (as it was originally) for simplicity, however when I click run in Eclipse I get an empty frame appear. As in just a white box, rather than one where I have set the size and background image to a .gif file of blue bubbles. I'm totally confused as to why this is behaving so different. Any help would be greatly appreciated.

S
 
K. Tsang
Bartender
Posts: 3648
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
where is the gif image "relative" to the java command? same directory or relative/absolute path? For relative it's relative to the directory where you run the program (from eclipse or not)
 
Stuie Clarky
Ranch Hand
Posts: 98
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my file system, I have the 3 images, the .java file and its .class file in the same directory. Which runs fine from the command line. In Eclipse I have the 3 images and the .java file in a new project in the src/default package directory. When clicking the run button in eclipse it pops up a window but no content
 
K. Tsang
Bartender
Posts: 3648
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Under eclipse the gif will either go under the src folder or the root of the eclipse project. Eg say your project is called ABC then you can put the images in C:\ABC.

I would try putting the images in root first.
 
Stuie Clarky
Ranch Hand
Posts: 98
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, so I have my src directory with my .java file, a resource directory with my 3 images, and after I build the project, my bin directory has the images and .class file. If I run the .class through terminal then it works (this is all in the eclipse workspace directory that it makes.

I'm just not understanding how it works one way but not the other.
 
Tony Docherty
Bartender
Posts: 3271
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's probably to do with what Eclipse considers the working directory to be and hence where your application looks for the gif files when run from within Eclipse. If you open the Run Configuration for you application and click on the Arguments tab you can set the working directory to the bin directory.
 
Stuie Clarky
Ranch Hand
Posts: 98
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yup that got it, nice one Tony

Stuie
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!