My path is all messed up, javac and python commands not found, I even uninstalled and reinstalled java. I would throw in random stuff from the internet into my terminal whenever my code wouldn't work and have subsequently ruined my path, I've even added stuff to my bash_profile and I don't know how to reset it or fix it. very frustrated. sorry I'm a noob
echo $PATH gives this:
Khalids-MacBook-Air:~ khalidhamid$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
~/.bash_profile gives this:
Khalids-MacBook-Air:~ khalidhamid$ ~/.bash_profile
-bash: /Users/khalidhamid/.bash_profile: Permission denied
javac Student.java gives this:
Khalids-MacBook-Air:java khalidhamid$ javac Student.java
javac: file not found: Student.java
Usage: javac <options> <source files>
use -help for a list of possible options
CodePudding user response:
There is nothing wrong with your javac, you just didn't specify the path to Student.java
correctly. Based on what you've told me, javac documents/java/Student.java
should work.
CodePudding user response:
Khalids-MacBook-Air:~ khalidhamid$ ~/.bash_profile -bash: /Users/khalidhamid/.bash_profile: Permission denied
That's normal. .bash_profile
is a script, yes, but it doesn't have the execute bit set. That's good. It shouldn't. If for some reason you want to execute it:
. ~/.bash_profile
Though, I have no idea why in the blazes you'd want to do that. It's already taken care of when you open a new terminal window (or a new tab in iTerm2.app or Terminal.app.
echo $PATH gives this:
Well, java and python are both in /usr/bin
, so you're fine. There's nothing wrong with your path. Macs ship with /usr/bin/python
and /usr/bin/java
, though they do not automatically lead to actual implementations: Those are wrapper executables that locate where you installed these things and then runs those. There is nothing wrong with your path.
javac: file not found: Student.java
This is saying that javac
was found and runs fine. javac
then complains that Student.java
doesn't exist.
You're simply in the wrong directory. Type ls
, which shows the contents. You'll find no Student.java
here. Go to the right directory first, or move Student.java
to the right directory if you're already there, or create it if it does not exist.
I would throw in random stuff from the internet into my terminal whenever my code wouldn't work
Yeah, don't do that.