0

I am trying to install JNetPcap and followed the instructions given at here. At step 12, I am unable to run the ant command and i see the error

Error: JAVA_HOME is not defined correctly.
We cannot execute /usr/lib/jvm/java-6-sun/bin/java

As I am able to run Java classes from eclipse or from command line I don't think if it's a problem with JAVA_HOME.

echo $PATH shows

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/lib/jvm/java-6-sun/bin

Kindly let me know if am missing something here.

thanks in advance

Raghuveer
  • 2,859
  • 7
  • 34
  • 66

1 Answers1

0

Neither running java from the command line or running eclipse will require JAVA_HOME to be set. However, the build procedure you are trying to use ant, and ant often does require JAVA_HOME to be set appropriately. (It actually depends on the version of ant that you are using. The use of JAVA_HOME is typically in the wrapper script for ant.)

Just set it.

JAVA_HOME should probably be set to /usr/lib/jvm/java-6-sun ... based on what you gave said PATH to.

However, it is also possible that the problem is that your PATH is incorrect. Or that you have (somehow) managed to get the owner/group/permissions on your Java install incorrect, such that the java command isn't executable.

  1. Check that running java -version displays the installed Java version.

  2. Repeat with /usr/lib/jvm/java-6-sun/bin/java -version.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
  • thanks for reply Stephen but my echo $JAVA_HOME shows the correct path /usr/lib/jvm/java-6-sun. Propbably i should have added it in my post. – Raghuveer Sep 17 '14 at 05:34
  • Did you try the other things that I suggested? – Stephen C Sep 17 '14 at 09:58
  • If you were unable to run "/usr/lib/jvm/java-6-sun/bin/java -version", that means that what you have in your PATH is incorrect; i.e. "/usr/lib/jvm/java-6-sun" is not the correct path to your Java installation. You should start by correcting PATH and JAVA_PATH to use the correct path. – Stephen C Sep 18 '14 at 07:07