Score:0

use a different Java version when executing .sh script in linux

au flag

We have Java 7 installed in our linux server but for a specific shell script, want to use a different version and execute. Below is the code I have in shell script, when I execute the shell script, it is not using the new java path set in the file. how can I set the java home for running this script?

#!/bin/bash            
export JAVA_HOME=/data/....          
export PATH=$JAVA_HOME/bin:$PATH       
JAVA=`which java`          
$JAVA -cp DataLoader.jar com.salesforce.dataloader.security.EncryptionUtil
Score:0
cn flag

Find where the Java (version) is installed first. They are commonly located at /usr/lib/jvm.

For example I've Java 8 and want to specifically execute with it.

#!/usr/bin/env bash

/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java -cp DataLoader.jar com.salesforce.dataloader.security.EncryptionUtil

If you have some bash scripting experience you can save this path in a variable and use it with it.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.