Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to compile all the java classes which are inside one package?

 
Chandrashekhar Kotekar
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
0 down vote favorite


Hi,

I am new to Java world. I have few classes which are inside nested folders (namespace).

My namespace has following folder structure (Assume that companyName folder is on C:\ ):



My problem is, I want to compile all of these classes from command prompt.

I tried the following command but its not working :



but its not working. I am getting following error :



Please help to compile all of these classes and possibly to create jar out of it.
 
Wim Vanni
Ranch Hand
Posts: 96
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would recommend the use of an IDE like Netbeans of Eclipse that will help you accomplish those tasks very easily. Other than that you could look into scripting this yourself (compile.bat file or something similar) or even better, making use of ant.

Cheers,
Wim
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chandrashekhar Kotekar wrote:0 down vote favorite


Chandrashekhar, please BeForthrightWhenCrossPostingToOtherSites
http://stackoverflow.com/questions/5962776/how-to-compile-java-classes-which-are-inside-multiple-folders
 
Tapan Maru
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are using a windows platform, you can create a batch file and write the order in which class needs to be compiled.
If you are using linux platform you can write a shell script.

OR alternatively,

use IDE (e.g. Eclipse, Netbeans...)
 
Jared Malcolm
Ranch Hand
Posts: 54
Java MySQL Database PHP
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From Oracle

FILE LIST

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



To me if you aren't willing to use an IDE then this seems like the best option.......list your files in one place and then just run command once (if i understand this correctly).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic