Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what syntax to compile java clases in subdirectory

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
What sytax do you use to compile a tree of directory in java?.
Example root/subroot1/subsubroot1/
if I am in root how do I write the sytax that will compile all .java files in all of those directories. javac *.java /.java does not work.
Thanks
Shloime
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please note that The Java Ranch has a naming policy, described here and "orshulim" is not a valid name. Please choose one which meets the requirements.
Thanks.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where do I change my name?
Thanks
Shloime
 
maha anna
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unfortunately, this forum s/w doen't have this feature. We have to re-register as new member. Thank you.
javac *.java will compile all .java files in current dir. I have used many times. Simillarly, if current dir is c:\test and there is a sub dir under test like c:\test\subTest we can compile all .java files under subTest dir from test dir like this.
c:\test\javac subTest\*.java
This will compile all *.java files under subTest and put all *.class files under subTest.
May be I don't get your question properly.
regds
maha anna

[This message has been edited by maha anna (edited December 14, 2000).]
 
Bhupinder Dhillon
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To shorten or simplify the javac command, you may specify one or more files that themselves contain one filename per line. On the command line, use the '@' character with the filename to specify it as a file list. When javac encounters an argument beginning with the character `@', it operates on the filenames in that file as if they had been on the command line. This enables you to overcome the command-line length limitation of Windows.
For example, you can list all of the source file names in a file named sourcefiles. This file might look like:
MyClass1.java
MyClass2.java
MyClass3.java
You could then run the compiler with:
C:> javac @sourcefiles
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks foe all of you.
My question is how can I compile all java files in root directory also in sub directory and in sub\sub directory. all together using a wild card.
javac *.java does only all files in this directory. but if I have 5 directory from root directory and each of the 5 have 3 directory. Ho do I command JAVAC to do recursive compiling.
I have a src.zip file that has a many directory files system how do I command javac to do this in one shot.
Thanks
Shloime
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"orshulim", please choose another name, that one will soon be switched off and you will no longer be able to log in to Java Ranch unsing it.
Thanks.
 
Bhupinder Dhillon
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There isn't a way to compile the whole packages. However, there is a work around - at least on windows.
Go to the top level package and type this in command prompt:
dir /b /s *.java >> files.txt
Then type: javac @files.txt
This will compile all the files, in all the sub-directories.
For example if your classes are in a folder called c:\classes
c:\>cd c:\classes
c:\classes>javac @files.txt
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks it worked.
Why when I try to compile
javac @src.zip
which has all the files it refuses to do so?
Thanks
Shloime
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic