12

I am following a Java tutorial that I should first browse to the JAR file that I have saved in Documents folder on my Mac..How do we go there by terminal commands?

Thanks

4 Answers 4

16

You should be able to write down in the console cd /Users/username/Documents/ when username is your user, then you can write ls to show a list of files in that folder.

7

You can type cd /Users/yourusername/Documents to go to your documents folder. cd is the terminal command to change the directory you're working in.

You can also type cd ~/Documents (~ is short for your home directory).

Finally, if you go to your home folder in the Finder, you can drag Documents onto the terminal window, and it will show the path to it. This is useful if you ever have a file or folder that you want to learn the path to.

2

This is all you need to do to run the jar file:

java -jar ~/Documents/jar

This is really what you want to do, as this runs the file you've created and the

cd ~/Documents/

command only sets the terminal to work in the Documents directory (i.e., folder), but little else.

2

After macOS Catalina (10.15), SIP (macOS sandbox) prevents the general folder access from the Terminal. See https://apple.stackexchange.com/questions/395631/allow-all-applications-to-access-desktop-documents-and-downloads-in-catalina

1
  • I get operation not permitted when trying to access downloads in terminal on Monterey.
    – Timo
    Apr 5, 2022 at 15:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .