-2

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

Oliver-R
  • 163
  • 1
  • 9
  • It sounds like you should be using an IDE. When you want to make and run a program you press the `Run` button and when you want to debug you press the `Debug` button. – Peter Lawrey Jan 01 '13 at 13:22
  • "I know that you can use some srt of set path command to fix this but nothing worked". That is ridiculous! If you want our help, you better give us all the details. – Werner Kvalem Vesterås Jan 01 '13 at 13:27

2 Answers2

0

I would recommend to look at existing build tools instead. Why? You ask for a reusable solution. From my experience, when it comes to building projects, once they become bigger, each has its own way. So a build tool has to be generic enough to satisfy all requirements. The solution that you provided in your question will not work for more complicated examples.

There are more sophisticated build tools out there but you may first look at Ant.

Philipp Claßen
  • 41,306
  • 31
  • 146
  • 239