I want to run a compiled .java/.class file that is located in a subfolder from the folder I am currently working in. I ran the command:
locate -br ^TheFileIWantToRun.java
so I know that the file is in the filepath:
/home/Me/Desktop/Folder1/Folder2/TheFileIWantToRun.java
I need to run this file from my current working directory:
/home/Me/Desktop/Folder1/
And I need to pass it a text file called test.
I have tried:
java -cp /home/Me/Desktop/Folder1/Folder2 TheFileIWantToRun test
But I get the error:
could not find or load the main class TheFileIWantToRun
Typically if the .java/.class file were in the same folder I would use:
java TheFileIWantToRun test
and this works.
How do I accomplish running a file from a different folder than the one I am in? Thank you.
cdinto that directory, call the program there and give it the full path to the text file ?