CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2000
    Posts
    2

    find javac in bat file

    I want to create bat file that finding javac (only one ,in my computer there is
    some jdk)then compile myProg.java with the founded javac.
    then run the file myProg.class.






  2. #2
    Join Date
    Sep 2000
    Location
    Melbourne --> Australia
    Posts
    68

    Re: find javac in bat file

    Hi there
    Ok here is how you can do it.
    In this example your java file is on Windows
    desktop.
    Step 1:
    Open a new file in notepad.
    Step 2:
    Type the following line in notepad>
    cd\windows\desktop
    Step 3:
    On the next line type the following>
    javac yourFile.java
    Step 4:
    On the next line type the following>
    java yourFile
    Step 5:
    Save this file as "Whatever.bat" on windows
    desktop, make sure you put the quotation marks around it as somtimes it will save
    the file as Whatever.bat.txt and you will be wondering why it wont work.
    Then you simply just double click on the batch file.
    You can also create a shortcut to this batch file.
    Good Luck Phill


  3. #3
    Join Date
    Sep 2000
    Posts
    2

    Re: find javac in bat file

    Hi,
    Thanks.
    I know how to create simple bat file and how to compile java code.
    My question is how to build th bat that searching in the computre
    javac and when finding some javac ,choose one
    and compile .
    I dont know where the jdk in the computre of the man that compile.


  4. #4
    Join Date
    Sep 2000
    Location
    Melbourne --> Australia
    Posts
    68

    Re: find javac in bat file

    Hi there
    If the man with the computer has
    his "Path" set correctly,
    then the batch file that i posted is all
    that you need.
    It changes the working directory to where the class file is,
    and dos will find javac.exe and java.exe if he has set his path correctly.

    Phill.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured