Home arrow static arrow Java Programming [Archive] - Java Compiler (javac -d)
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - Java Compiler (javac -d)
This topic has 4 replies on 1 page.

Registered: 8/5/04
Java Compiler (javac -d)   
Aug 5, 2004 11:18 AM

I am trying to compile a series of Java files via a Korn shell script. I am running into to trouble using the -d option when the source file is under a directory. Assume the following

Directory A contains directories source and classes

Source contains 3 directories A, B, & C, each of which have a java source file.

classes contains no directories and no files.

When I compile the file a.java in directory A I recieve an error message that classes/a doesn't exisit.

My questions are as follows.

1) Can the compilier create the missing directories. If yes how.
2) Is it possible to tell the compiler to just put all the .class files in the directory.

Any help would be greatly appreciated.



Registered: 7/13/04
Re: Java Compiler (javac -d)   
Aug 5, 2004 11:23 AM (reply 1 of 4)

what are you using? eclipse? jbuilder? text editor?

Registered: 4/7/04
Re: Java Compiler (javac -d)   
Aug 5, 2004 11:43 AM (reply 2 of 4)

post your command line.

Assuming all java files are in the same directory:
JAVAC -help //get help on javac commandCD {directory of java files (not classes)}JAVAC -d classes *.java

Registered: 4/7/04
Re: Java Compiler (javac -d)   
Aug 5, 2004 12:03 PM (reply 3 of 4)

In your case, the source files are in different directories:

1) Create a directory called classes in your project directory
2) Create a text file src_myproject.txt in your project directory
3) List the path to all the java source files in file you just created
4) Do the following
cd {project directory}javac  -d classes @src_myproject.txt //incluce classpath if needed

javac doesn't create the classes directory, but it will create the rest according to their package.

Registered: 6/18/03
Re: Java Compiler (javac -d)   
Aug 6, 2004 10:51 AM (reply 4 of 4)

I am not sure I fully understand your question, because what I think you are saying that you are doing works fine:

[elof@hugin elof]$ cd /tmp/ [elof@hugin tmp]$ mkdir A[elof@hugin tmp]$ cd A[elof@hugin A]$ mkdir source classes[elof@hugin A]$ mkdir source/A source/B source/C[elof@hugin A]$ echo "package A; public class MyClass {}" >>source/A/MyClass.java[elof@hugin A]$ javac -d classes/ source/A/MyClass.java [elof@hugin A]$ ls -l classes/A/MyClass.class -rw-------    1 elof     users         190 aug  6 19:50 classes/A/MyClass.class[elof@hugin A]$ 
This topic has 4 replies on 1 page.