making a .bat file that compiles your java files
I made a .bat file that would compile my java files for a visual basic project that im doing. This is the code for the batch file:
Quote:
@echo off
title Java Compiler
:start
javac *java
pause
goto start
When it gets called from my project i get this error:
Quote:
javac: invalid flag: *java
Usage: javac <options> <source files>
use -help for a list of possible options
Press any key to continue . . .
However when i run this file from the directory its placed it it works fine. Any ideas about whats wrong?
Re: making a .bat file that compiles your java files
Re: making a .bat file that compiles your java files
now i get this error:
Quote:
javac: file not found: *.java
Usage: javac <options> <source files>
use -help for a list of possible options
Press any key to continue . . .
Re: making a .bat file that compiles your java files
Just to step back a bit...why not use an IDE such as Eclipse to do all this work for you?
Back to the problem at hand, the file must be in the proper location relative to where javac is being executed (aka where the .bat file is).
Re: making a .bat file that compiles your java files
I can't use eclipse because this is a Visual Basic Project. I'm making my own Java IDE in Visual Basic. In Visual Basic the file i mentioned gets put into the same folder as the java files and it just doesn't work when it gets called.
Re: making a .bat file that compiles your java files
Don't put *.java, you need to replace this with the actual file name.
Code batch:
rem this will compile a file named test.java
javac test.java
There are also various parameters you will need to consider when building via command-line. I won't go into the details for each one, but these are the main ones:
1. Multiple source files
2. packages/multiple packages, nested packages
3. external libraries.
You can also pass in command-line arguments for batch files. I can't remember the exact semantic, but I believe it's something like this:
Code batch:
rem this is build.bat
rem this will compile a file named specified in the first parameter
javac %1
Then, to use this batch file: