CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Installation (
-   -   Getting OpenFOAM to coexist with an existing JAVA VM (

nik777 February 22, 2007 05:06

Hi all, Firstly, may I say
Hi all,

Firstly, may I say I am very impressed with what I've seen of OpenFOAM.

I have a query regarding the installation - I hope it doesn't appear that I'm complaining.

OpenFOAM runs fine for me (as far as I have tested), but the installation of OpenFOAM has broken my existing JAVA installation.

I develop and use a lot of JAVA on my machine, and cannot afford to have JAVA broken by another application.

Is there something I've done wrong, or can do differently to get OpenFOAM to coexist with my java installation?

The problem is that the OpenFOAM .basrc unconditionally sets JAVA_HOME, JAVA_PATH and JAVA_ROOT to the OpenFOAM java installation dir.
It also sets CLASSPATH to '.'.

This breaks my other java applications which I wish to run using the VM (JDK 1.6) I have already installed in /usr/java/jdk, and with a CLASSPATH which includees various extensions including JMF and JOGL.

One 'simple' solution which seems apparent is to have the various OpenFOAM tools source the .bashrc file, rather than relying on it being sourced *before* those tools are run. In this way, the OpenFOAM environment settings would be per-process, rather than for every shell I ever run.

However, there is quite probably a better solution already provided, and if so I would be very thankful if someone could point me in the right direction.

Thanks again for such a powerful took.


mattijs February 22, 2007 05:34

There is no specific reason to
There is no specific reason to use the OpenFOAM java version. Does it work out of the box with your java version? If not you can rebuild FoamX with your java. (Allwmake in $FOAM_UTILITIES/preProcessing/FoamX)

nik777 February 22, 2007 05:52

Hi Mattijs, Thank you for y
Hi Mattijs,

Thank you for your quick response.

> Does it work out of the box with your java version?
Yes, OpenFOAM works with the 1.6 VM that I already have (once I've fixed the environment variables).

My problem isn't that OpenFOAM doesn't work; my problem is that if I source the OpenFOAM .bashrc from my regular .bashrc, then none of my other JAVA apps run.

Does the 'make' you are suggesting rebuild the .bashrc file with different contents? If so, how do I get it to contain the values I need?
As importantly, how do I get it to leave the CLASSPATH variable alone?

Just to be clear: my problem is that ~/OpenFOAM/OpenFOAM-1.3/.bashrc changes the values of the following JAVA environment variables:


The values that are set stop many other JAVA applications on my machine from running.

Therefore, I am looking for a solution in which OpenFOAM has the values it needs for these variables, and my other JAVA applications have the values that they need, which I have previously configured.

Thanks again for your time and help.


dmoroian February 22, 2007 06:56

A simple work around would be
A simple work around would be to not source ~/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/bashrc in your ~/.bashrc file.
Whenever you want to run OpenFOAM, open an xterm and source ~/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/bashrc. This way you will restrict the environment variables to only one bash session which belongs to the xterm.
The rest of the system will still use the old values.


olesen February 22, 2007 08:13

The following snippet might gi
The following snippet might give you want you need. NB: the indenting gets lost by the mailer.

# Java
# ~~~~
# avoid altering exising configurations
# compatability issues remain with the user
if [ ! -d "$JAVA_HOME" ]; then

case `uname -s` in
export JAVA_HOME=$WM_PROJECT_INST_DIR/$WM_ARCH/j2sdk1.4.2_05

[ `uname -m` = ia64 ] && JAVA_HOME=/usr/java/j2sdk1.4.2




export PATH=$JAVA_PATH/bin:$PATH
export CLASSPATH=.

7islands February 22, 2007 08:21

Hello, I do basically the sam
I do basically the same as Dragos. I have a line in my ~/.bashrc:

alias foamSetup='if test "x$WM_PROJECT" != "xOpenFOAM"; then source ~/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/bashrc; fi'

and run "foamSetup" in the terminal where I want to run OpenFOAM applications.


All times are GMT -4. The time now is 06:01.