Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have installed jdk-7u3-linux-i586.tar.gz according to this:

How do I install Oracle Java JDK 7?

But when I try to install java_ee_sdk-6u4-unix.sh using the command sudo sh java_ee_sdk-6u4-unix.sh from inside the /home//Downloads/ directory I get the message

Could not locate a suitable jar utility. Please ensure that you have Java 6 or newer installed on your system and accessible in your PATH or by setting JAVA_HOME

Note: Even though I get the mesage "Could not locate a suitable jar utility. Please ensure that you have Java 6 or newer installed on your system and accessible in your PATH or by setting JAVA_HOME" commands "java", "javac" are working from any location.

share|improve this question
    
Just out of interest, Which version of Ubuntu are you using? If it is 11.10 or 12.04, then openjdk-7-jdk is in the repository. –  Chris Woollard Apr 23 '12 at 22:02
    
@Chris Woollard-Yes Chris openjdk-7 is in the repository But I wanted to use Sun JDK7 with java_ee and also to explore how to do a manual installation, can you figure out what's going on I am using 11.10-Varuna –  Varuna Apr 24 '12 at 1:58
    
@RedFred this works for me +1 thanks –  beplicant Jul 27 at 11:00

4 Answers 4

up vote 2 down vote accepted

The problem is the same that for other programs (java, javac, javaws etc.) You just need to create an update alternative for the "jar" program like this:

sudo update-alternatives --install "/usr/bin/jar" "jar" "/usr/lib/jvm/jdk1.7.0/bin/jar" 1

Note: remember to replace the "jdk1.7.0" path by the real name of your target jdk installation path if it is different.

share|improve this answer
  • Download the .tar.gz package from here.
  • Unzip it to a location ( say ~/java/ )
  • run
     update-alternatives --install "/usr/bin/java" "java" 
    ( Assuming that you have update-alternatives installed already. You should, if you you openjdk installed.)

Those steps should make java available globally.

share|improve this answer
    
@Shggylnjun-I have installed Java according to this How do I install Oracle Java JDK 7? and is already globally available<quote>Note: Even though I get the message "Could not locate a suitable jar utility. Please ensure that you have Java 6 or newer installed on your system and accessible in your PATH or by setting JAVA_HOME" commands "java", "javac" are working from any location</quote> The question is even though Java is globaly available why is JavaEE installation asking for a jar utility –  Varuna Apr 24 '12 at 7:58
    
askubuntu.com/questions/122133/… Take a look at that post. It should solve your JAVA_HOME problems. But I wonder what you are trying to do that creates this error. Considering how java development outside IDE is almost unimaginable, I say configure JDK inside the IDE, you can avoid a bunch of other issues. –  ShaggyInjun Apr 24 '12 at 23:50
    
When are people going to learn that JAVA_HOME has nothing to do with being able to run Java other than being a variable which clients can use to see where Java is? A simple symbolic link of all the bin contents to the /usr/bin will get Java up on most Unixes I've tried.... –  thejartender Apr 25 '12 at 20:58

The quick-and-dirty solution:

At the command prompt type:

sudo apt-get install jarwrapper fastjar

Now, when you run ./java_ee_sdk-6u4-unix.sh again, it should install without a hitch.

share|improve this answer
#!/bin/bash
#Author: Yucca Nel http://thejarbar.org
#Will restart system
#Modify these variables as needed...
tempWork=/tmp/work
locBin=/usr/local/bin
javaUsrLib=/usr/lib/jvm

sudo mkdir -p $javaUsrLib
mkdir -p $tempWork
cd $tempWork

#Update this line to reflect newer versions of JDK...
wget --no-cookies --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2Ftechnetwork%2Fjava%2Fjavase%2Fdownloads%2Fjdk-7u3-download-1501626.html;" http://download.oracle.com/otn-pub/java/jdk/7u3-b04/jdk-7u3-linux-i586.tar.gz

#Extract the download
tar -zxvf $tempWork/*

#Move it to where it can be found...

sudo mv -f $tempWork/jdk1* $javaUsrLib/

sudo ln -f -s $javaUsrLib/jdk1*/bin/* /usr/bin/
sudo rm -rf $tempWork
#Update this line to reflect newer versions of JDK...
export JAVA_HOME="$javaUsrLib/jdk1.7.0_03"

if ! grep "JAVA_HOME=$javaUsrLib/jdk1.7.0_03" /etc/environment
then
    echo "JAVA_HOME=$javaUsrLib/jdk1.7.0_03"| sudo tee -a /etc/environment
fi


exit 0
share|improve this answer
    
@thejartender-Can you please explain this I am not able to grasp what this does? –  Varuna Apr 24 '12 at 21:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.