Converting Java batch file from windows to unix format

Discussion in 'Java' started by arun.hallan@gmail.com, Apr 10, 2005.

  1. Guest

    My java application includes source files in packages, and jar
    library's in a lib directory.
    I have created a windows batch file that compiles all and then runs the
    application.
    It is in the form of "javac classpath[jar files] [all package folders]
    java classpath[jarfiles] [MainClass]"
    The batch file is as so:


    ___________________________________________________________________
    javac -classpath
    "lib\jdom.jar;lib\ant.jar;lib\ant-launcher.jar;lib\liquidlnf.jar;lib\tools.jar"
    antigen\builders\*.java antigen\config\*.java

    antigen\datastructure\*.java antigen\gui\*.java antigen\io\*.java
    antigen\listeners\*.java antigen\wizard\*.java

    java -classpath
    ".;lib\jdom.jar;lib\ant.jar;lib\ant-launcher.jar;lib\liquidlnf.jar;lib\tools.jar"
    antigen.config.Antigen
    ____________________________________________________________________



    I have attempted to create a unix version of this (well i have tried to
    make it work in mac os 10).
    I have created a script that will run when i call "source BatchFile"
    from the command prompt.
    The script is as follows:


    ______________________________________________________________________
    javac -classpath
    /lib/jdom.jar:/lib/ant.jar:/lib/ant-launcher.jar:/lib/liquidlnf.jar:/lib/tools.jar
    antigen/builders/*.java antigen/config/*.java

    antigen/datastructure/*.java antigen/gui/*.java antigen/io/*.java
    antigen/listeners/*.java antigen/wizard/*.java

    java -classpath
    ".;/lib/jdom.jar;/lib/ant.jar;/lib/ant-launcher.jar;/lib/liquidlnf.jar;/lib/tools.jar"
    antigen.config.Antigen
    ______________________________________________________________________


    Java attempts to compile the source, but it doesnt include the jar
    files in the classpath. Therefore i get a lot of library specific
    errors.
    Does anyone know why? Does unix work with the classpath differently?
    Can someone help me create a batch file for a unix system.

    Thanks



    PS I do not want to use a build tool, as the whole point of the
    application is to allow use of ant without installing it.
    , Apr 10, 2005
    #1
    1. Advertising

  2. Lans Redmond Guest

    in unix you need to set the classpath
    example

    export CLASSPATH=myjar.jar:another.jar

    so you will need to add this to your script
    <> wrote in message
    news:...
    > My java application includes source files in packages, and jar
    > library's in a lib directory.
    > I have created a windows batch file that compiles all and then runs the
    > application.
    > It is in the form of "javac classpath[jar files] [all package folders]
    > java classpath[jarfiles] [MainClass]"
    > The batch file is as so:
    >
    >
    > ___________________________________________________________________
    > javac -classpath
    >

    "lib\jdom.jar;lib\ant.jar;lib\ant-launcher.jar;lib\liquidlnf.jar;lib\tools.j
    ar"
    > antigen\builders\*.java antigen\config\*.java
    >
    > antigen\datastructure\*.java antigen\gui\*.java antigen\io\*.java
    > antigen\listeners\*.java antigen\wizard\*.java
    >
    > java -classpath
    >

    ".;lib\jdom.jar;lib\ant.jar;lib\ant-launcher.jar;lib\liquidlnf.jar;lib\tools
    ..jar"
    > antigen.config.Antigen
    > ____________________________________________________________________
    >
    >
    >
    > I have attempted to create a unix version of this (well i have tried to
    > make it work in mac os 10).
    > I have created a script that will run when i call "source BatchFile"
    > from the command prompt.
    > The script is as follows:
    >
    >
    > ______________________________________________________________________
    > javac -classpath
    >

    /lib/jdom.jar:/lib/ant.jar:/lib/ant-launcher.jar:/lib/liquidlnf.jar:/lib/too
    ls.jar
    > antigen/builders/*.java antigen/config/*.java
    >
    > antigen/datastructure/*.java antigen/gui/*.java antigen/io/*.java
    > antigen/listeners/*.java antigen/wizard/*.java
    >
    > java -classpath
    >

    ".;/lib/jdom.jar;/lib/ant.jar;/lib/ant-launcher.jar;/lib/liquidlnf.jar;/lib/
    tools.jar"
    > antigen.config.Antigen
    > ______________________________________________________________________
    >
    >
    > Java attempts to compile the source, but it doesnt include the jar
    > files in the classpath. Therefore i get a lot of library specific
    > errors.
    > Does anyone know why? Does unix work with the classpath differently?
    > Can someone help me create a batch file for a unix system.
    >
    > Thanks
    >
    >
    >
    > PS I do not want to use a build tool, as the whole point of the
    > application is to allow use of ant without installing it.
    >
    Lans Redmond, Apr 10, 2005
    #2
    1. Advertising

  3. EricF Guest

    Lans is correct but this may help ...

    In *nix, the path and classpath separator is :
    On Windows, it is ;

    HTH

    Eric

    In article <LU06e.6509$>, "Lans
    Redmond" <> wrote:
    >in unix you need to set the classpath
    >example
    >
    >export CLASSPATH=myjar.jar:another.jar
    >
    >so you will need to add this to your script
    ><> wrote in message
    >news:...
    >> My java application includes source files in packages, and jar
    >> library's in a lib directory.
    >> I have created a windows batch file that compiles all and then runs the
    >> application.
    >> It is in the form of "javac classpath[jar files] [all package folders]
    >> java classpath[jarfiles] [MainClass]"
    >> The batch file is as so:
    >>
    >>
    >> ___________________________________________________________________
    >> javac -classpath
    >>

    >"lib\jdom.jar;lib\ant.jar;lib\ant-launcher.jar;lib\liquidlnf.jar;lib\tools.j
    >ar"
    >> antigen\builders\*.java antigen\config\*.java
    >>
    >> antigen\datastructure\*.java antigen\gui\*.java antigen\io\*.java
    >> antigen\listeners\*.java antigen\wizard\*.java
    >>
    >> java -classpath
    >>

    >".;lib\jdom.jar;lib\ant.jar;lib\ant-launcher.jar;lib\liquidlnf.jar;lib\tools
    >..jar"
    >> antigen.config.Antigen
    >> ____________________________________________________________________
    >>
    >>
    >>
    >> I have attempted to create a unix version of this (well i have tried to
    >> make it work in mac os 10).
    >> I have created a script that will run when i call "source BatchFile"
    >> from the command prompt.
    >> The script is as follows:
    >>
    >>
    >> ______________________________________________________________________
    >> javac -classpath
    >>

    >/lib/jdom.jar:/lib/ant.jar:/lib/ant-launcher.jar:/lib/liquidlnf.jar:/lib/too
    >ls.jar
    >> antigen/builders/*.java antigen/config/*.java
    >>
    >> antigen/datastructure/*.java antigen/gui/*.java antigen/io/*.java
    >> antigen/listeners/*.java antigen/wizard/*.java
    >>
    >> java -classpath
    >>

    >".;/lib/jdom.jar;/lib/ant.jar;/lib/ant-launcher.jar;/lib/liquidlnf.jar;/lib/
    >tools.jar"
    >> antigen.config.Antigen
    >> ______________________________________________________________________
    >>
    >>
    >> Java attempts to compile the source, but it doesnt include the jar
    >> files in the classpath. Therefore i get a lot of library specific
    >> errors.
    >> Does anyone know why? Does unix work with the classpath differently?
    >> Can someone help me create a batch file for a unix system.
    >>
    >> Thanks
    >>
    >>
    >>
    >> PS I do not want to use a build tool, as the whole point of the
    >> application is to allow use of ant without installing it.
    >>

    >
    >
    EricF, Apr 10, 2005
    #3
  4. In article <>,
    wrote:
    [...]
    > ______________________________________________________________________
    > javac -classpath
    > /lib/jdom.jar:/lib/ant.jar:/lib/ant-launcher.jar:/lib/liquidlnf.jar:/lib/tools
    > .jar
    > antigen/builders/*.java antigen/config/*.java
    >
    > antigen/datastructure/*.java antigen/gui/*.java antigen/io/*.java
    > antigen/listeners/*.java antigen/wizard/*.java
    >
    > java -classpath
    > ".;/lib/jdom.jar;/lib/ant.jar;/lib/ant-launcher.jar;/lib/liquidlnf.jar;/lib/to
    > ols.jar"
    > antigen.config.Antigen
    > ______________________________________________________________________
    >
    > Java attempts to compile the source, but it doesnt include the jar
    > files in the classpath. Therefore i get a lot of library specific
    > errors.

    [...]

    Under unix, the classpath separator is ":", not";". Also, the
    current path "." must be in the classpath for both compilation and
    execution. I may be helpful to define your classpath once and use it
    as needed:

    #!/bin/sh
    CLASSPATH=.:/lib/jdom.jar:/lib/ant.jar:...
    javac -classpath $CLASSPATH antigen/builders/*.java ...
    java -classpath $CLASSPATH antigen.config.Antigen

    --
    John
    jmatthews at wright dot edu
    www dot wright dot edu/~john.matthews/
    John B. Matthews, Apr 10, 2005
    #4
  5. Nigel Wade Guest

    Lans Redmond wrote:

    > in unix you need to set the classpath
    > example
    >
    > export CLASSPATH=myjar.jar:another.jar


    No you don't. You can set the classpath on the javac command in exactly the
    same way as you can in any other supported OS.

    --
    Nigel Wade, System Administrator, Space Plasma Physics Group,
    University of Leicester, Leicester, LE1 7RH, UK
    E-mail :
    Phone : +44 (0)116 2523548, Fax : +44 (0)116 2523555
    Nigel Wade, Apr 11, 2005
    #5
  6. Nigel Wade Guest

    wrote:

    > My java application includes source files in packages, and jar
    > library's in a lib directory.
    > I have created a windows batch file that compiles all and then runs the
    > application.
    > It is in the form of "javac classpath[jar files] [all package folders]
    > java classpath[jarfiles] [MainClass]"
    > The batch file is as so:
    >
    >
    > ___________________________________________________________________
    > javac -classpath
    >

    "lib\jdom.jar;lib\ant.jar;lib\ant-launcher.jar;lib\liquidlnf.jar;lib\tools.jar"
    > antigen\builders\*.java antigen\config\*.java
    >
    > antigen\datastructure\*.java antigen\gui\*.java antigen\io\*.java
    > antigen\listeners\*.java antigen\wizard\*.java
    >
    > java -classpath
    >

    ".;lib\jdom.jar;lib\ant.jar;lib\ant-launcher.jar;lib\liquidlnf.jar;lib\tools.jar"
    > antigen.config.Antigen
    > ____________________________________________________________________
    >



    These jar files have been specified with a relave path.


    >
    >
    > I have attempted to create a unix version of this (well i have tried to
    > make it work in mac os 10).
    > I have created a script that will run when i call "source BatchFile"
    > from the command prompt.
    > The script is as follows:
    >
    >
    > ______________________________________________________________________
    > javac -classpath
    > /lib/jdom.jar:/lib/ant.jar:/lib/ant-launcher.jar:/lib/liquidlnf.jar:/lib/tools.jar
    > antigen/builders/*.java antigen/config/*.java
    >
    > antigen/datastructure/*.java antigen/gui/*.java antigen/io/*.java
    > antigen/listeners/*.java antigen/wizard/*.java
    >
    > java -classpath
    >

    ".;/lib/jdom.jar;/lib/ant.jar;/lib/ant-launcher.jar;/lib/liquidlnf.jar;/lib/tools.jar"
    > antigen.config.Antigen
    > ______________________________________________________________________
    >


    These jar files have been specified with an absolute path. Are you jar files
    in the /lib directory, or in the lib sub-directory of the current working
    directory?

    Also, change the semi-colons into colons in all the command lines. A
    semi-colon in UNIX shell is a command-line separator.

    >
    > Java attempts to compile the source, but it doesnt include the jar
    > files in the classpath. Therefore i get a lot of library specific
    > errors.
    > Does anyone know why? Does unix work with the classpath differently?


    No, it works in exactly the same way with the classpath, except the delimter
    is a colon not a semi-colon.


    --
    Nigel Wade, System Administrator, Space Plasma Physics Group,
    University of Leicester, Leicester, LE1 7RH, UK
    E-mail :
    Phone : +44 (0)116 2523548, Fax : +44 (0)116 2523555
    Nigel Wade, Apr 11, 2005
    #6
  7. Aquila Deus Guest

    wrote:
    > My java application includes source files in packages, and jar
    > library's in a lib directory.
    > I have created a windows batch file that compiles all and then runs

    the
    > application.
    > It is in the form of "javac classpath[jar files] [all package

    folders]
    > java classpath[jarfiles] [MainClass]"
    > The batch file is as so:
    >
    >
    > ___________________________________________________________________
    > javac -classpath
    >

    "lib\jdom.jar;lib\ant.jar;lib\ant-launcher.jar;lib\liquidlnf.jar;lib\tools.jar"
    > antigen\builders\*.java antigen\config\*.java
    >
    > antigen\datastructure\*.java antigen\gui\*.java antigen\io\*.java
    > antigen\listeners\*.java antigen\wizard\*.java
    >
    > java -classpath
    >

    ".;lib\jdom.jar;lib\ant.jar;lib\ant-launcher.jar;lib\liquidlnf.jar;lib\tools.jar"
    > antigen.config.Antigen
    > ____________________________________________________________________
    >
    >
    >
    > I have attempted to create a unix version of this (well i have tried

    to
    > make it work in mac os 10).
    > I have created a script that will run when i call "source BatchFile"
    > from the command prompt.
    > The script is as follows:
    >
    >
    >

    ______________________________________________________________________
    > javac -classpath
    >

    /lib/jdom.jar:/lib/ant.jar:/lib/ant-launcher.jar:/lib/liquidlnf.jar:/lib/tools.jar
    > antigen/builders/*.java antigen/config/*.java
    >
    > antigen/datastructure/*.java antigen/gui/*.java antigen/io/*.java
    > antigen/listeners/*.java antigen/wizard/*.java
    >
    > java -classpath
    >

    ".;/lib/jdom.jar;/lib/ant.jar;/lib/ant-launcher.jar;/lib/liquidlnf.jar;/lib/tools.jar"
    > antigen.config.Antigen


    extract & dump all jars into jre/classes, then you won't need to deal
    with classpath anymore :)
    Aquila Deus, Apr 11, 2005
    #7
  8. In article <LU06e.6509$>,
    "Lans Redmond" <> wrote:

    > in unix you need to set the classpath
    > example
    >
    > export CLASSPATH=myjar.jar:another.jar
    >
    > so you will need to add this to your script


    Not true. You do not NEED to set the CLASSPATH variable on any OS.
    I've got my app running on Windows, Mac OS X and Linux and NONE of them
    have a CLASSPATH variable set.
    --
    Steve W. Jackson
    Montgomery, Alabama
    Steve W. Jackson, Apr 12, 2005
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. pomegran
    Replies:
    1
    Views:
    373
    Gordon Beaton
    Oct 1, 2003
  2. Replies:
    5
    Views:
    717
    Magnus Lycka
    Oct 27, 2006
  3. islamelnaggar
    Replies:
    4
    Views:
    2,976
    islamelnaggar
    Feb 24, 2008
  4. islamelnaggar
    Replies:
    0
    Views:
    475
    islamelnaggar
    Feb 24, 2008
  5. Replies:
    6
    Views:
    366
    Dr J R Stockton
    Mar 6, 2007
Loading...

Share This Page