How to use relative paths when compiling?
I have a directory structure as such:
c:\javaprogram
----- build
----- src
----- classes
----- lib
Within the classes I will have my compiled class and within src is the source code NewClass.java. lib contains my .jar files.
In the build directory I have a .bat file that I use to compile the source code into the .class which is stored in the classes folder.
My build.bat file looks like:
set root_dir=c:\javaprogram
javac -d %root_dir%\classes\ -classpath %root_dir%\classes;%root_dir%\lib\one.jar; -sourcepath %root_dir%\src %root_dir%\src\NewClass.java
This works fine.
For reasons I won't go into this root diretory will change as this folder will be copied multiple times so ideally what I'd have is instead of root_dir pointing to a fullpath
I can just use a relative path so that my .bat file would look something like:
javac -d ..\classes\ -classpath ..\classes;%root_dir%\lib\one.jar; -sourcepath ..\src ..\src\NewClass.java
were the .. signifies that I'm running this batch file from the build directory so go up one level and down into the src folder to find the .java file.
This above doesn't work and I get a file ..\src\NewClass.java not found error.
Is this possible? If so, how?
Thanks