# Install OpenJDK 8 but java -version still 1.7



## edisonch (Sep 19, 2015)

Dear All,

I follow the guide to install OpenJDK8 in FreeBSD 10.x but I still get 1.7 from `java -version`? I use OpenJDK7 for more than couple years but now a software forces me to upgrade for 1.8 thus I install OpenJDK8.

What should I do to make OpenJDK8 as the default of `java -version` in FreeBSD 10.x?

Thank you in advance.


----------



## edisonch (Sep 19, 2015)

Dear All,

Sorry I just found the solution myself at
http://phosphor-escence.blogspot.co.id/2012/01/install-opnejdk7-on-freebsd.html

To be clear, do the following if you get the same problem I have with having multiple JDK in a server:

`vi /etc/make.conf`

```
JAVA_VENDOR=openjdk
JAVA_VERSION=1.8
BOOTSTRAPJDKDIR=/usr/local/openjdk8
JAVA_PREFERRED_PORTS=JAVA_PORT_NATIVE_OPENJDK_JDK_1_8
```

Based on URL above and it works for me.


----------



## tobik@ (Sep 19, 2015)

Setting JAVA_VERSION=1.8 in your environment would suffice (see javavm(1)).


----------



## junovitch@ (Sep 19, 2015)

tobik is correct and that solution is fair simpler than changing /etc/make.conf.  For example, if the application is started by a shell script, you can add this in to set the needed environmental variables.

```
JAVA_VERSION="1.8+"
export JAVA_VERSION
```


----------

