# sun jdk 1.6 under FreeBSD 8.1



## choudharypranay (Dec 25, 2010)

Hi,
I have successfully installed sun-jdk-1.6 under FreeBSD 8.1, but when i run
	
	



```
$java -version
```
i get this error:
	
	



```
$ java -version ELF binary type "0" not known.
/usr/local/linux-sun-jdk1.6.0/bin/java: 1: Syntax error: "(" unexpected
```

I installed sun-jdk by ports:

```
1.	# cd linux_base-fc4/
	# make install clean

2.	paste jdk-6u22-linux-i586.bin in /usr/ports/distfiles

3.	# cd /usr/ports/java/linux-sun-jdk16/
	make install clean

4.	#reboot
```

Where did I go wrong?
Thanks in advance.


----------



## choudharypranay (Dec 25, 2010)

I was troubleshooting this. I'm quite near to a solution.

I add these lines in /etc/rc.conf: 
	
	



```
linux_enable="YES"
```
then added two environment variables: 
	
	



```
setenv JAVA_HOME "/usr/local/linux-sun-jdk1.6.0/"
setenv LD_LIBRARY_PATH /usr/local/linux-sun-jdk1.6.0/jre/lib/i386/jli
```

Now there are two problems in this. 
First, after setting these environment variables, if i run java -version, i get this warning:

```
Java HotSpot(TM) Client VM warning: Can't detect initial thread stack location - find_vma failed
java version "1.6.0_22"
Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
Java HotSpot(TM) Client VM (build 17.1-b03, mixed mode)
```

Second, the environment variable does not persist if i reboot my machine. I tried fixing it by writing a shell script containing the setenv commands and placed it under /root/bin. But then when i run java -version as a normal user, I get the same error of ELF binary type "0" not known.


I googled for "Set environment variables permanently in FreeBSD", but did not get any useful result. please help.


----------



## SirDice (Dec 25, 2010)

Use emulators/linux_base-f10. Fc4 is really old.

Also set in /etc/make.conf:

```
JAVA_PREFERRED_PORTS?=JAVA_PORT_LINUX_SUN_JDK_1_6
```

That's all I had to do:


```
dice@molly:~>java -version
java version "1.6.0_22"
Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
Java HotSpot(TM) Server VM (build 17.1-b03, mixed mode)
dice@molly:~>
```


----------



## choudharypranay (Dec 26, 2010)

SirDice said:
			
		

> That's all I had to do:
> dice@molly:~>java -version
> java version "1.6.0_22"
> Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
> ...



Thanks for the reply. I already tried it.

```
1. pkg_remove -v -r linux_base-fc4-4
2. pkg_remove -v -r linux-sun-jdk-1.6.0.22
3. add JAVA_PREFERRED_PORTS?=JAVA_PORT_LINUX_SUN_JDK_1_6 in make.conf
4. pkg_add -v -r linux_base-f10
5. cd /usr/ports/java/linux-sun-jdk16 -> make install clean
6. java -> /usr/local/linux-sun-jdk1.6.0/bin/java: error while loading shared libraries: libjli.so: cannot open shared object file: No such 
file or directory
```

I had no errors while installing java.


----------



## SirDice (Dec 26, 2010)

Make sure java/javavmwrapper is properly installed. It should be installed as a dependency of linux-sun-jdk16.

I don't have that libjli anywhere so I'm wondering why it's looking for it.


----------



## choudharypranay (Dec 26, 2010)

SirDice said:
			
		

> Make sure java/javavmwrapper is properly installed


Yes, javavmwrapper is already installed. Are you using FreeBSD 8.1? 'Cos a friend of mine has reported that same procedure works on FreeBSD 8.0
Well, I'm going to test it myself on 8.0.

Thanks.


----------



## choudharypranay (Dec 26, 2010)

one more question....
is there any way to install sun jdk by using pkg_add? ports take a lot of time for installation...


----------



## choudharypranay (Dec 26, 2010)

SOLVED IT FINALLY.

Just add this line in etc/fstab

```
linprocfs   /compat/linux/proc   linprocfs   rw   0  0
```

Sun jdk version "1.6.0_22" on FreeBSD 8.1


----------

