I am new to Java world. I have got few classes which are inside nested folders.
My namespace has following folder structure (Assume that companyName folder is on C:\ ):
companyName -> isuName -> projectName -> module1 -> sampleclass1.java companyName -> isuName -> projectName -> module2 -> sampleclass2.java companyName -> isuName -> projectName -> module3 -> codePart3.1 -> sampleclass3.java companyName -> isuName -> projectName -> module3 -> codePart3.2 -> sampleclass4.java
My problem is, I want to compile all of these classes from command prompt.
I tried the following command but its not working :
C:\> javac -sourcepath companyName\*.java
but its not working. I am getting following error :
javac: no source files
Usage: javac <options> <source files>
Please help to compile all of these classes and possibly to create jar out of it.
I looked at the manual page for javac, and it seems you’ll have to spell out the source files on the command line, or you’ll have to list them in a separate file, and reference that file on the command line.
I set up the first two source files in your question in a similar tree, and compiled them as follows:
Using the other method, I produced this file:
Then I fed that file to the javac compiler, prepending the “@” specifier per the manual.
The manual page for jar doesn’t seem to yield the same techniques, so I specified the files on the command line as before.
Of course, doing it this way is somewhat tedious, so I highly recommend Ant, which you can run on Windows.