# Using JDK 7 (Java with FreeBSD)



## ikevinjp (Jun 27, 2012)

Hi, I tried to to a *make install* for JDK7 at java/openjdk7, and was thrown with an error saying the license does not permit auto-install, and that I need to download it myself.

Then, I use the command *pkg_add -r openjdk7*. The installation was successful, but I seems that it is quite an old version:

```
openjdk version "1.7.0"
OpenJDK Runtime Environment (build 1.7.0-root_2011_12_06_00_20-b00)
OpenJDK 64-Bit Server VM (build 21.0-b17, mixed mode)
```
So, is the JDK port actively maintained? (The latest version is JDK 7 Update 5).

Otherwise, what is the best way to use the latest Java version? (Actually, I need to run GlassFish and Tomcat.)

Thanks!

Kevin


----------



## SirDice (Jun 27, 2012)

ikevinjp said:
			
		

> and was thrown with an error saying the license does not permit auto-install, and that I need to download it myself.


Just follow the directions. It's not that difficult.



> Then, I use the command *pkg_add -r openjdk7*. The installation was successful, but I seems that it is quite an old version:
> 
> ```
> openjdk version "1.7.0"
> ...


You probably installed the version that came with the -RELEASE.

Set your PACKAGESITE to ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-9-stable/Latest


----------



## jnbek (Jun 27, 2012)

Even better:
[CMD=""]cd /usr/ports/java/openjdk7;make install clean[/CMD]


----------



## jnbek (Jun 27, 2012)

I see that you did [CMD=""]make install[/CMD] it... I don't remember having that problem when I installed it. I do remember getting a little murphed when something I installed demanded openjdk6 as a dependency. But initially, I installed version 7 from ports and it didn't give me any grief at all. I'm under the impression that OpenJDK is supposed to be the open source java, so accepting a license seems inappropriate; though I have a lengthy history of being wrong, who knows.


----------



## SirDice (Jun 27, 2012)

Funny enough you need Java to be able to build Java from source. It's a bit of a chicken and egg problem.

Open source doesn't mean it's free to use, hence the license


----------



## kpa (Jun 27, 2012)

If you have what it takes you can write the first compiler directly in assembly language  Which is exactly how the world's first C compiler was produced.


----------



## mrgz (Jun 27, 2012)

As far as I know, Diablo JDK installation requires manual download of the JDK package via website, due to check the licence agreement. On new FreeBSD installations, when I had no java compilers at all, OpenJDK required a bootstrap Java compiler to solve the chicken and egg problem. So I've downloaded Diablo JDK (wich is a binary distribution).

Do you really need Java 7? I have to deal with Java software and Java 6 environment seems to be more stable, specially with Glassfish (v2, ou our case).


----------



## jnbek (Jun 27, 2012)

*Y*ou know, I think I *pkg_add -r openjdk7*, then *portupgrade*'d it later on to get it to build from source.


----------



## SirDice (Jun 28, 2012)

That should work too. As I said you need Java to be able to build Java. If there's nothing installed it'll use java/diablo-jdk16 but once java/openjdk7 is installed you should be able to use openjdk7 to build openjdk7.


----------

