# Cannot switch java VM



## mky (Sep 27, 2010)

Hi,
I have installed two versions of java and javavm wrapper:

```
diablo-jdk-1.6.0.07.02_10 Java Development Kit 1.6.0_07.02
javavmwrapper-2.3.5 Wrapper script for various Java Virtual Machines
openjdk6-b20_3      Oracle's Java 6 virtual machine release under the GPL v2
```
I tried to switch between this javas, removing one of this from /usr/local/etc/javavms but it always run diablo-jdk. I also tried unregister one of VM, using 
`# unregistervm /usr/local/diablo-jdk1.6.0/bin/java`
It also doesn't work for me. When I check current version of java, I have:

```
$ java -version
java version "1.6.0_07"
Diablo Java(TM) SE Runtime Environment (build 1.6.0_07-b02)
Diablo Java HotSpot(TM) 64-Bit Server VM (build 10.0-b23, mixed mode)
```

How can I switch properly to other java VM? I would like to run always openjdk when I need, and sometimes diablo-jdk for compatibility issues (eg. for JDownloader).


----------



## achix (Mar 27, 2011)

Sorry to come to this late. The reason you are facing this, is because javavm wrapper port has gotten extremely misleading. Solve this by applying this patch to /usr/ports/Mk/bsd.java.mk

```
*** bsd.java.mk.orig	2011-03-27 08:33:34.000000000 +0300
--- bsd.java.mk	2011-03-27 08:42:33.000000000 +0300
***************
*** 212,217 ****
--- 212,219 ----
  # Enforce preferred Java ports according to OS
  .		if (${OSVERSION} >= 600000 && ${OSVERSION} < 800000)
  _JAVA_PREFERRED_PORTS+=	JAVA_PORT_NATIVE_FREEBSD_JDK_1_6
+ .		else if (${OSVERSION} >= 800000)
+ _JAVA_PREFERRED_PORTS+=	JAVA_PORT_NATIVE_OPENJDK_JDK_1_6
  .		else
  _JAVA_PREFERRED_PORTS+=	JAVA_PORT_NATIVE_BSDJAVA_JDK_1_6
  .		endif
```


----------



## achix (Mar 27, 2011)

pr submitted here:
http://www.freebsd.org/cgi/query-pr.cgi?pr=java/155967


----------



## achix (Mar 27, 2011)

update:
make else if->elif


----------

