Alex M
Alex M

Reputation: 1

Setting environment variables and path in MacOS 10.11.6

this is my first stackoverflow question so please don't skewer me too hard. I've searched and found some answers to this question, but nothing has worked so far. I'm trying to install Apache Ant for use with my Compilers class, and am having trouble figuring out how to properly set my path and environment vars.

I'm editing my /.profile, not /.bash_profile as that doesn't exist. Is that my main issue? Do both need to exist and be identical? I've followed this and this and neither has worked. I have MacPorts installed, but it doesn't seem to be updated. Also I'm not entirely sure how to set "ant" as the environment variable to be able to use the command "ant" to run ant. I can post my current files and paths if needed

Edit: echo $PATH now returns: /opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/Library/Frameworks/Python.framework/Versions/3.5/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:$j/j--/bin:$ANT_HOME/bin:/Users/Alex/desktop/school/cs/cs451/apache-ant-1.10.0/bin

$j/j-- is a folder with code for my class given by the professor.

I created a .bash_profile file that is now identical to my .profile file. Now I'm getting an error: UnsupportedClassVersionError -> Unsupported major.minor version 52.0 error when I run "ant"

Possibly I downloaded incompatible versions of Java and Ant, or my JAVA_HOME variable is incorrect?

Upvotes: 0

Views: 1650

Answers (2)

Alex M
Alex M

Reputation: 1

So this seemed to be the underlying issue. I couldn't get Java to play nice with anything while only downloading the JRE and not the JDK, every time I tried a "java -version" or any sort of command to find the java version installed, it pointed to a version 1.7 even though I specified 1.8 in my PATH and I had installed the JRE for 1.8. Installing the JDK (which I ran into the problem of it hanging on install for which this fixed my issue) and reopening a terminal window in my j-- directory and running "ant" everything worked perfectly. Thanks for your help sideshow and Andy!

Upvotes: 0

Andy
Andy

Reputation: 61

You can create one by

vi ~/.bash_profile

Here is an example of my .bash_profile with maven and java.

M2_HOME=/usr/local/apache-maven/apache-maven-3.1.1
export M2_HOME

PATH=$PATH:$M2_HOME/bin
export PATH

export JAVA_HOME="$(/usr/libexec/java_home -v 1.8)"

Upvotes: 2

Related Questions