Topic
2 replies Latest Post - ‏2011-01-15T03:51:54Z by JavinPaul
nan123
nan123
1 Post
ACCEPTED ANSWER

Pinned topic run java program using bat file

‏2010-12-08T04:45:52Z |
I want to run a simple hello world java (HelloWorld.java) program using a batch file. How can i run it and how to construct a batch file. kindly let me know
Updated on 2011-01-15T03:51:54Z at 2011-01-15T03:51:54Z by JavinPaul
  • SystemAdmin
    SystemAdmin
    210 Posts
    ACCEPTED ANSWER

    Re: run java program using bat file

    ‏2010-12-27T23:20:47Z  in response to nan123
    Invoking java class from bat file is simple.
    Do you have basic knowledge on DOS/Windows batch file ?
    In your batch file specify the following commands
    1. add jdk bin folder to your PATH
    2. javac <your javafile>
    3. java <your class file generated from step 2>

    save this file as *.bat and execute it. if you are using any specify libraries then add it in classpath
  • JavinPaul
    JavinPaul
    1 Post
    ACCEPTED ANSWER

    Re: run java program using bat file

    ‏2011-01-15T03:51:54Z  in response to nan123
    Hi,

    Batch file (.bat) is nothing but a text file with .bat extension and generally we store commands on it (like shell script in unix) and when we invoke it from command prompt , DOS execute those commands. so by putting "java classname" in batch file you can invoke your program but yes its good idea to set PATH and CLASSPATH inside batch file for convinience.

    Thanks
    Javin

    Why String is immutable in Java FIX Protocol tutorial tibco tutorial