0

My system need to use java 1.7. However, I need to run some old apps which require java1.6. Can I use shell script to let the old apps use correct java version? Could the $JAVA_HOME work?

I try to set export JAVA_HOME=/usr/lib/jvm/java-6-openjdk-amd64 However, it does not has any effect.

4
  • 1
    Yes, it sounds like using a shell script and $JAVA_HOME could work. What have you tried? Commented Jul 6, 2015 at 6:31
  • 2
    Also set $PATH too ? Commented Jul 6, 2015 at 6:32
  • JAVA_HOME itself seems does not work. Do I need to set PATH? Commented Jul 6, 2015 at 6:38
  • I would just create a one line wrapper script and call the specific java virtual machine explicitly. Commented Jul 6, 2015 at 7:53

1 Answer 1

1

On some systems there is a command that is called java-config or java-config-2 that helps you selecting a java vm when you have multiple JDK or JRE versions installed with your system installer. But basically you want to call your java app with the java binary that should live somewhere near $JAVA_HOME. I would guess $JAVA_HOME/bin/java.

The $JAVA_HOME helps the called java program finding it's libraries, but it doesn't help your command line finding the right java binary.

2
  • 1
    set $PATH works also. But I think directly call the $JAVA_HOME/bin/java is better. Commented Jul 6, 2015 at 8:03
  • That depends on how temporary you call your old app and if you need to use more tools from the $JAVA_HOME/bin, but to answer the question I thought it would be best to be most specific and let you decide about your PATH variable yourself ;) Commented Jul 6, 2015 at 8:05

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.