Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Jiddick ExRex

macrumors 65816
Original poster
May 14, 2006
1,469
0
Roskilde, DK
So I have had enough of most IDEs and would like to stay clear from them as I have discovered the power of using Emacs/Aquamacs for typing pretty much anything.
Thus I need some sort of introduction to how to import packages (java files) from other folders than the directory I am working in.

My current working directory:
~/Documents/Java/HelloWorld/

Say I need to import ' edu.umd.cs.piccolo.nodes.PText ' from the folder ~/Documents/Java/piccolo/build/...
(I don't want to have to copy the whole directory to the /HelloWorld/ folder although that works fine. I need to import independently of projects/folders/current applications), how do I go about doing this?

In the file ~/Documents/Java/HelloWorld/HelloWorldExample.class I need to import it by writing import edu.umd.cs.piccolo.nodes.PText; but this clearly doesn't work, as I need to point a directory level up and then further into the piccolo/build/edu/... folders.

What is the syntax for doing this? In the terminal it would be ' ../ 'but it obviously doesn't work, since traversing directories/packages is done with ' . ' .

Help would be much appreciated, since I cannot seem to google answers to this...
 

pilotError

macrumors 68020
Apr 12, 2006
2,237
4
Long Island
Wouldn't you just change your classpath variable?

You can also add the classpath on the java command line

java -classpath /Users/myusername/Documents/Java/piccolo/build/

or in terminal

export CLASSPATH=~/Documents/Java/piccolo/build/
 

Jiddick ExRex

macrumors 65816
Original poster
May 14, 2006
1,469
0
Roskilde, DK
Thanks.

Even after exporting to said directory, and running ' java ~/Documents/Java/HelloWorld/HelloWorldExample.class ' I get a noClassDefFoundError. It makes it compile though.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.