Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

I installed java jdk hotspot 1.7. When I type java -version I am getting:

java version "1.7.0" 
Java(TM) SE Runtime Environment (build 1.7.0-b147)

This is correct.

And I tried to install maven, and added to etc/environment file:


Now When I type mvn I am getting:

Error: JAVA_HOME is not defined correctly.   We cannot execute

However I am not putting " mark for JAV_HOME var in environment file.

It is trying to run from


path, Actually it should be


When I command


I am getting:

bash: ”/usr/lib/jvm/jdk1.7.0”: No such file or directory

I am sure the path(/usr/lib/jvm/jdk1.7.0) is correct.

Please advise how to fix.

Thanks in advance

share|improve this question

closed as too localized by Marco Ceppi Aug 13 '12 at 2:00

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

Can you do an ls -al /usr/lib/jvm and confirm that 'jdk1.7.0' is the format for the directory name? When using Oracle, they tend to use weird folder names – Thomas W. Jun 29 '12 at 13:16
ls /usr/lib/jvm/java-7 and ls "/usr/lib/jvm/java-7"/bin yield, and should yield the same result for me (which is not empty). The last part, java-7, is the result of a manual modification - it can and will be a bit different for you. Verify, that such a folder exists (jdk1.7.0). – user unknown Jun 29 '12 at 13:50
I got total 44 drwxr-xr-x 3 root root 4096 Jun 28 01:57 . drwxr-xr-x 184 root root 36864 Jun 28 01:34 .. drwxr-xr-x 10 root root 4096 Jun 27 23:30 jdk1.7.0 after running this ls -al /usr/lib/jvm command – Kamoliddin Jun 29 '12 at 23:31
Note that to see a variable in your console, you are expected to type: echo $VARNAME. If you just do $VARNAME then it will execute what's in that variable. – Alexis Wilke Apr 19 at 23:31

1 Answer 1

JAVA_HOME should be set to the name of the directory that contains the bin directory that contains the Java executables (in particular, java itself).

Assuming you do have a /usr/lib/jvm/jdk1.7.0 directory, it probably contains a jre subdirectory that contains the bin directory that contains java and related executables.

So you should probably be setting JAVA_HOME to /usr/lib/jvm/jdk1.7.0/jre rather than /usr/lib/jvm/jdk1.7.0.

share|improve this answer
Installing a JDK, not just the JRE usually lead to a JDK-directory containing a bin dir, as well as a JRE-dir, which itself contained a bin dir. But JAVA_HOME was always set to the parent dir, not to the jre dir. – user unknown Jun 29 '12 at 13:54
Interesting, I need to set it to jdk no? I am going to write code in java, compile, deploy, etc.. – Kamoliddin Jun 30 '12 at 0:03
@Kamoliddin If Maven is using $JAVA_HOME to know where javac and other development binaries are, then yes, you'll need to set it to the jdk dir containing the bin dir that contains those binaries. – Eliah Kagan Jun 30 '12 at 5:32
Thanks, I do not know, it worked after restart, I think i do not need to restart for changes to be applied. I did not change anything. It worked. – Kamoliddin Jul 1 '12 at 5:19
Not sure why he using jdk1.7.0 at all.. /usr/lib/jvm/java should suffice for both java and javac. Alternatives takes care of this – staticx Apr 25 '14 at 17:01

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