javabatch-file

Is a way to compile a .java file using batch, but so that the batch file can be reused?


IS there a way to make a batch file that: 1. Opens cmd 2. asks for a filepath 3. complies the targeted file 4. runs the product I know how to do this like so:

@echo off
javac Filename.java
java  Filename

The only prolems are: 1. i want to make it reusable (so that it asks for a filepath) 2. the window briefly shows the error that javac is not a regonized command and then closes. is there anyway to do what i want to do? I know that you can use some srt of set path command to fix this but nothing worked. if it helps my jdk is at C:/program Files/java/jdk1.7.0_10/bin


Solution

  • Have a look at these questions:

    How to read input from console in a batch file?

    Problem with user input in my batch file

    how do i get a batch file to accept input from a txt file?

    User Input - DOS batch file

    and many more ...