At 02:16 PM 6/15/99 +0100, Christian Nentwich wrote:
>
>> javac [COMPILE_OPTIONS] BUFFER_NAME.java
>> Note that the cd command that appears in the compile buffer is just there
>> for appearances. The JDE does not actually change directories because
>> it doesn't need to do so. The working directory of the current buffer is
>> the directory containing the source file.
>> If you can give me a compelling reason for compiling from the package
>> parent directory, I'd consider implementing it as a JDE option.
>
>Well, I've got a compelling enough reason. If you have a package called
>'test' and some source files, e.g. Bogus.java
>
>package test;
>
>public class Bogus {
>
>}
>
>and you have files in a directory about test, i.e. the root.. so it
>would be
>
>Foo.java
>test\Bogus.java
>
>In addition, suppose Bogus depends on Foo:
>
>package test;
>import Foo;
>
>Now if you compile Bogus by 'cd test; javac Bogus.java' the compiler
>will barf because it won't find foo.. in fact that just happened to me
>with JDE because I forgot to click on the upper window :)
>
>Java files in packages need to be compiled like this:
>javac test\Bogus.java
>javac Foo.java
>
>That's the only way that works as far as I know..
>
Hi Christian,
I have lots of similar cases in the projects I'm working on and I have no
problems,
because of the way I setup my projects.
Here's how I set up my typical Java project directory:
proj_dir
class
lib
src
com
bluehills
pkg1
class1A.java
class1B.java
...
pkg1_1
class1_1A.java
class1_1B.java
...
pkg2
class2A.java
class2B.java
...
...
Here's my classpath for this project:
-classpath
proj_dir/src;proj_dir/class;proj_dir/lib/lib1.jar;jdkdir/jre/1.2/lib/rt.jar
Note that I include the root of the source directory in my classpath. This
allows jikes, the compiler I use, to resolve references to uncompiled
classes (by compiling the classes).
I set the JDE compiled files directory option to proj_dir/class.
Now suppose that class1_1A depends on class1B. In this case, the source
file for class1_1A starts off
// This is the source for class1_1A.
package com.bluehills.pkg1.pkg1_1;
import com.bluehills.pkg1.class1B;
When I compile class1_1A, the JDE constructs the following command
cd proj_dir/pkg1/pkg1_1
jikes -classpath
proj_dir/src;proj_dir/class;proj_dir/lib/lib1.jar;jdkdir/jre/1.2/lib/rt.jar
-d proj_dir/class +E class1_1A.java
With this setup, my package structure can be elaborate as I want
and jikes never has any trouble finding required classes.
- Paul