I am making my own programming language called "Mast" in java for my study. I made a compiler called "cmpmast" that works similarly to javac and gcc in that it is a command-line application.
I compiled the java project for this compiler to a .exe file and put it in folder that I added to PATH (windows 10). Everything seems to work fine except for finding the input files:
say we have a folder like "C:\users\me\desktop\folder" which contains the empty file "hello.mast".
when I open the cmd, change the directory to that folder and execute the command C:\users\me\desktop\folder>cmpmast hello.mast, the program is unable to find the file.
After some debugging, I found out that it is not looking inside the cd of the cmd but inside the folder in which I put the cmpmast.exe file.
To find a file, I simply used the java.io.File class like so: File inputFile = new File(pathname); where pathname is the argument passed to my compiler (cmpmast).
How would I get the cd of the system console (cmd) I am running my compiler in, from inside the java program? I assume this to be possible since all command-line compilers I have used worked like this.
I already tried to use System.getProperty("user.dir") and it resulted in the same unwanted path.