Compiling multiple java

Hi. I have a question on how to compile many .java files, which are stored in various dirrectories (packages). There are literally hunderds of files. All are stored in a dirrectory tree that takes orign in .. let's say .. "Src" and branches down from it.
I specifically want to use 'javac' compiler.
When I am the 'src' folder I want to say
prompt> javac [option] *.java
Now I'm not sure what that option is. It basically have to tell the OS to compile all files in all the subdirectories of src and their corresponding subdirectories. A recursive compilation that is.
Would appreciate any help.
Thanks

prompt> javac [option] *.java
Now I'm not sure what that option is.There is no option to "recursively" compile .java source files.
Unlike some languages the source file name and the name of the
directories it is in are intimately related to the type of the class being
compiled. You specify a .java source file (or multiple source files) and
using what it knows about the source file names, and what you set
the classpath to be, the compiler will determine what needs to be
compiled and where the source files are located.
Have you read the documentation for javac?
http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/javac.html
The command (or commands) you use will almost certainly involve
the -d option to set the destination directory, the -classpath option to
set the classpath and possibly the -sourcepath option. There are
examples given for both compiling multiple files, and compiling where
source and class files are in separate directories.
If you obtained these files from somewhere it might be a good idea to
consult whatever documentation is available. In particular you are
looking for some description of the "build" process. Building a large,
related, set of files could involve installing and using a tool like Ant.

Similar Messages

  • Compiling multiple java files present in different packages simultaneously

    Hi,
    I have multiple java files which are present in different folders.
    In some cases, files are importing classes from other packages i.e. some kind of inter-dependency
    How do I compile these java files simultaneously?
    Any help would be highly appreciated.

    Pawan_Anand wrote:
    Hi,
    I have multiple java files which are present in different folders.
    In some cases, files are importing classes from other packages i.e. some kind of inter-dependency
    How do I compile these java files simultaneously?
    Is it circular?
    Thus the dependency is A => B => C => A?

  • Error when compiling multiple java code files

    Hi,
    Since I installed J2SDK downloaded from this website, it has never compiled my code correctly when written in multiple java files. Below is a sample of my code and the error message I am getting:
    File#1
    class testprint{
    public static void main(String args[]){
         myprint mp = new myprint();
         mp.manageprint();
    File#2
    class myprint{
    void manageprint(){
         System.out.print("please print");
    Here is my error message from the command line:
    c:\print>javac testprint.java
    testprint.java:4: cannot resolve symbol
    symbol : class myprint
    location: class testprint
         myprint mp = new myprint();
    ^
    testprint.java:4: cannot resolve symbol
    symbol : class myprint
    location: class testprint
         myprint my = new myprint();
                   ^
    2 errors
    C:\
    It seems Java is not recognizing myprint.java file. Do I need to configure anything to make my code work? Please help!
    Thanks in advance.

    Are both files in the same directory? Is the directory in your classpath?

  • How to compile multiple java programs.

    Hi,
    I have different java classes located in a hierarchy of folders, how can I complile all of them in a batch and place all class files in a specified folder ?

    You can specify more than one file "javac file1.java file2.java" and use the file wildcard. "javac directory1\*.java directory2\*.java"
    Keep in mind that javac will use the Classpath to find classes.

  • Deployment Error -- JSP Compilation Error: java.lang.OutOfMemoryError -- nu

    When I deploy WAR files with the precompile jsp option, I receive the following error:
    Deployment Error -- JSP Compilation Error: java.lang.OutOfMemoryError -- null
    Is there a way for me to precompile my jsp's without using this process? Once this blows up, the admin server gets hosed. This is very frustrating. Any suggestions would be appreciated.
    Regards,
    Joshua

    You need little more memory :-), use java param -mx512M.
    You can adjust it in OC Server properties
    AS > OC4J_home(demo) > Server Properties
    section Multiple VM Configuration, Command Line Options
    Java Options: -mx512M
    Zajo

  • Compiling multiple files?

    This is kind of a theory question.
    when you compile a file that has references to other files(all files are in the same package), isnt the compiler supposed to check that those other files have been compiled and if they are not, then isnt it supposed to compile them as well. For example;
    public class MainFrame {
    public MainFrame () {
    super ();
    // init ();
    //testUnits ();
    init2 ();
    private void init2 () {
    FDocument document = new FDocument ();
    FPage page = new FPage ();
    FFrame rectangle = new FFrame ();
    FParagraph header = new FParagraph ();
    FFrame pageFrame = new FFrame ();
    FFrame footer = new FFrame ();
    FFrame testRectangle = new FFrame ();
    FFrame childRectangle = new FFrame ();
    when I compile MainFrame, should it not also compile FDocument, FPage, FFrame etc as well?
    at present I get the errors cannot resolve symbol: class FDocument etc.
    As well, where I have a file FPrintObject which contains a reference to another file FPage such as
    public FPrintObject(FPage pg){
    shouldnt it compile FPage when I compile FPrintObject?
    I get the same cannot resolve symbol error, and they are definitely in the same package.
    any suggestions? Thanks alot in advance. OZ!!
    PS I have to reference that code snippet, it was from an excellent article in Javaworld autjhored by Jean-Pierre Dube "Printing in Java".

    Ok, thanks alot guys, looks like I was mistaken in my understanding of how the compiler worked, That pretty much cleared it up. It looks like the easiest way to do it is through and IDE(I' m using JCreator LE) by using the build batch function. If I wanted to do it through the Dos Prompt, How would I do it?
    At present I would normally do;
    c:Print>c:\j2sdk1.4.0-rc\bin\javac MainFrame.java
    as quoted above
    No, only the file(s) you specify on the javac command> is(are) compiled. If you want to compile multiple
    > files at a time, then you need to specify them all as
    > arguments to the javac command.
    >
    so what would be the entry in order to specify them all as arguments to the javac command?
    using the example above if I also wanted to compile FDocument, FPage, FFrame.
    with regard to classpath, I have it set to
    path=c:\windows;c:\windows;c:\windows\command\j2sdk1.4.0-rc\bin
    Thanks, you're help is great.

  • Compiling Multiple Files using JDK1.3.1

    C:\jdk1.2.2\bin\javac -d C:\classes -classpath <some classpath> C:\release\*.java
    The above works fine in the CMD promt of WIN2K server.
    C:\jdk1.3.1\bin\javac -d C:\classes -classpath <some classpath> C:\release\*.java
    This doesn't work, same error type is thrown for multiple files: "cannot resolve symbol".
    I think the problem seems to be in the autocompile, i.e while compiling a java file, the javac compiles all the import files (if class files don't exist). This happens in JDK1.2.2, but not in JDK1.3.1
    Any pointers to solve this problem.
    Thankx

    If your class uses another class from a package which is not compiled already
    it will throw this error. To overcome this just include the path to all the packages
    that your class uses in your classpath.
    Fx,
    you want to compile xxx.java and yyy.java in c:\javatest\
    But to compile these above two files you also have to compile files
    in c:\javatest\test\files\aaa.java and c:\javatest\test\files\bbb.java
    then you should have c:\javatest\ in your classpath.
    hope this helps.
    cheers.Also you should have the follwing import statements in xxx.java and yyy.java
    import test.files.aaa;
    import test.files.bbb;
    aaa.java and bbb.java can be compiled from c:\javatest\test\files\
    but alternatively, if you don't have the files compiled...when you compile
    xxx.java or yyy.java they should be compiled automatically, provided you
    have included the proper import statements.
    All the best !

  • My class only compiles in Java 1.6 and not in Java 1.5

    Hi, my java class wont compile in java 1.5, it only compiles in Java 1.6. How can i compile the following?
    import java.util.*;
    public class ShoppingBasket
         Vector products;
         public ShoppingBasket() { products = new Vector(); }
         public void addProduct(Product product)
         boolean flag = false;
         for(Enumeration e = getProducts(); e.hasMoreElements();)
              { Product item = (Product)e.nextElement();
                   if(item.getId().equals(product.id))
                   {flag = true; item.quantity++; break; }
              if(!flag){ products.addElement(product);}
         public void deleteProduct(String str)
              for(Enumeration e=getProducts();
              e.hasMoreElements();)
              { Product item = (Product)e.nextElement();
                   if(item.getId().equals(str))
                   {products.removeElement(item); break; }
         public void emptyBasket(){products = new Vector();}
         public int getProductNumber(){ return products.size();}
         public Enumeration getProducts() { return products.elements(); }
         public double getTotal()
         Enumeration e = getProducts();
         double total; Product item;
         for(total=0.0D;e.hasMoreElements();     total+= item.getTotal())
         {item = (Product)e.nextElement(); }
         return total;
    }It should link with a class called Product which compiles fine... the errors i get are below:
    K:\jakarta-tomcat-5.0.18\webapps\ROOT\WEB-INF\classes\ShoppingBasket\ShoppingBas
    ket.java:6: cannot find symbol
    symbol  : class Product
    location: class ShoppingBasket
            public void addProduct(Product product)
                                   ^
    K:\jakarta-tomcat-5.0.18\webapps\ROOT\WEB-INF\classes\ShoppingBasket\ShoppingBas
    ket.java:10: cannot find symbol
    symbol  : class Product
    location: class ShoppingBasket
                    { Product item = (Product)e.nextElement();
                      ^
    K:\jakarta-tomcat-5.0.18\webapps\ROOT\WEB-INF\classes\ShoppingBasket\ShoppingBas
    ket.java:10: cannot find symbol
    symbol  : class Product
    location: class ShoppingBasket
                    { Product item = (Product)e.nextElement();
                                      ^
    K:\jakarta-tomcat-5.0.18\webapps\ROOT\WEB-INF\classes\ShoppingBasket\ShoppingBas
    ket.java:20: cannot find symbol
    symbol  : class Product
    location: class ShoppingBasket
                    { Product item = (Product)e.nextElement();
                      ^
    K:\jakarta-tomcat-5.0.18\webapps\ROOT\WEB-INF\classes\ShoppingBasket\ShoppingBas
    ket.java:20: cannot find symbol
    symbol  : class Product
    location: class ShoppingBasket
                    { Product item = (Product)e.nextElement();
                                      ^
    K:\jakarta-tomcat-5.0.18\webapps\ROOT\WEB-INF\classes\ShoppingBasket\ShoppingBas
    ket.java:35: cannot find symbol
    symbol  : class Product
    location: class ShoppingBasket
            double total; Product item;
                          ^
    K:\jakarta-tomcat-5.0.18\webapps\ROOT\WEB-INF\classes\ShoppingBasket\ShoppingBas
    ket.java:36: inconvertible types
    found   : <nulltype>
    required: double
            for(total=0.0D;e.hasMoreElements();     total+= item.getTotal())
                                                                         ^
    K:\jakarta-tomcat-5.0.18\webapps\ROOT\WEB-INF\classes\ShoppingBasket\ShoppingBas
    ket.java:37: cannot find symbol
    symbol  : class Product
    location: class ShoppingBasket
            {item = (Product)e.nextElement(); }
                     ^
    8 errors

    fahafiz wrote:
    ah, so should i put the classes into the folder which the classpath is assigned to?More likely you should assign your classpath to whatever folder your classes are in.
    Put your files where they make sense, and then fill in classpath accordingly:
    javac -classpath classpath MyFile.java(I think, it's been a while since I compiled from the command-line, see http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/javac.html)

  • How to compile a java file which is in memory?

    how to compile a java file which is in memory?
    such as:
    String s="class MyClass {....}";
    how to compile the string?
    thx

    come on ...That was a perfectly valid solution.
    Do you know how to call the sun.* compiler? If not then search the forums for it. If that interface still exists (which it might not in newer versions) you then will create a string stream from your class and pass it to that.

  • Problem in compiling this java need help

    package test;
    public class simpleTest{
         public simpleTest(){
              int a =0;
    import test.*;
    public class testPackage{
         public static void main(String [] args){
              simpleTest sT=new simpleTest();
              System.out.println("Package from Test A value = "+a);
    }error got when compile this codes.
    --------------------Configuration: <Default>--------------------
    C:\Notes\testPackage.java:4: cannot access simpleTest
    bad class file: C:\Notes\simpleTest.java
    file does not contain class simpleTest
    Please remove or make sure it appears in the correct subdirectory of the classpath.
    simpleTest sT=new simpleTest();
    ^
    1 error
    Process completed.

    package test;
    public class simpleTest{
    private int a;
         public simpleTest(int a){
              // int a =0;
    this.a = a;
    public int getA() {
    return a;
    =============== 2 diff files===================
    import test.*;
    public class testPackage{
         public static void main(String [] args){
              simpleTest sT=new simpleTest();
    System.out.println("Package from Test A value =
    = "+st.getA());
    }- Saishu can compile the java package?

  • Urgent! Pls help me! Can't compile any *.java files

    I am a new user to Java2SDK. I am using Win2K sever and I have installed Java2SDK1.4.0 in D drive. When I compile any *.java files, a message " 'javac' is not recognized as an internal or external command, operable program or batch file" appears. How can I solve this problem?
    Please help me. I am busy with my homework. Thank you very much.

    In your PATH variable include %JAVA_HOME%\bin;
    For example:
    C:\jdk1.4\bin;

  • How to Use Multiple Java Runtimes

    Hi,
    I have installed two JRE versions (1.2.2 and 1.4.0_01) in my Machine (Windows platform).
    (The default if 1.2.2 as it was installed later)
    I want to run an application in either of the above JRE's. To do so...
    If I want to run the application on 1.2.2
    I use C:\jdk1.2.2\bin\java MyApplication
    If I want to run the application on 1.4
    I use C:\jdk1.4\bin\java MyApplication
    Basically I am hardcoding the path where the "java" executable lies..
    Now my question is, Is this the correct/only way to use different JRE's?? Is there any other cleaner way to use multiple java runtimes??
    There is some parameter for "java.exe" where we can set version
    like "java -Dversion=1.4.0_01". Can this be helpful??
    Thanks in advance
    Hiten

    You could use DOS environment variables to define the jre path to use.

  • How to compile a java file in J9 for windows mobile 5.0

    I have downloaded J9 for windows mobile 5.0 and need help on how to compile a java file.

    You can compile your source code using J2SE ;)
    may be this is important for you:
    http://awareness.ics.uci.edu/~rsilvafi/pocketPC/index.
    html
    Regards!!!Actually i am using some eSWT related classes also.. so is there any way to compile from the J9 environment using J9 console..

  • How to compile a java file in a java program

    Hi,
    I don't know to compile a java file in a java class.
    Could somebody help me?
    Thanks.

    if ur using windows...
    goto ur directory and then type
    javac FILENAME.java
    and ur done!

  • How to compile my java application for Personal Java??

    i write a simple program and want to run it in PJEE.
    program is:
    import java.awt.*;
    public class TestApp {
    public static void main(String[] args) {
    Frame f = new Frame();
    f.pack();
    f.setSize(300,300);
    f.show();
    and i compiled it using JDK1.4
    javac TestApp.javathen i want to test it by using pjava
    pjava TestAppbut i got a error message:
    Error loading class TestApp: Bad major version numberplease tell me what it is mean and how i can debug it, thanks.

    hi, all
    i have resolved my question by myself.
    because:
    |-> personal java
    |
    jdk1.1 -> jdk1.2 -> jdk1.4
    so, i must compile the java file by using jdk1.1.x
    :)

Maybe you are looking for