Eclipse unable to locate Java in Ubuntu - java

While I am trying to install the Payara server on my Ubuntu machine after putting the path of the Payara/glassfish server when I try to put the java location whatever i give as path is considered as error. I use Oracle java 10 and as I put the value "/usr/lib/java/jdk-10.0.1/" it says its not a jdk. Path for Java 10 has been properly set in ~/.bashrc as
export JAVA_HOME=/usr/lib/java/jdk-10.0.1/
export PATH="$PATH:JAVA_HOME/bin"
Why is this behaving in this way? Can anybody suggest me a way out.

try export PATH=$PATH:${JAVA_HOME}/bin

Your shell is interpreting JAVA_HOME as string, you forgot a $ before JAVA_HOME in the export PATH line to make it interpret as a variable.

Related

Could not find any executable java binary

please help with my problem that I'm facing since hours. I'm trying to run ElasticSearch-5.2.2 with MEAN Stack. I installed Java JDK 8 and I set the path correctly and also added this path "\Oracle\Java\javapath" still I'm getting the same error "Could not find any executable java binary. Please install java in your PATH or set JAVA_HOME". Why it is happening can anyone help me out?
You said you "went to environment variables and added variable name: JAVA_HOME variable value: C:\Program Files\Java\jdk1.8.0_121\bin"
This is incorrect. Don't include the bin directory when you set JAVA_HOME.
Set JAVA_HOME to C:\Program Files\Java\jdk1.8.0_121
Once you are done with this, test it.
Open command prompt and type echo %java_home% and see if its printing the path you set.
Are you using Windows?
If so open your system environment variables and add a new one named JAVA_HOME and point it to your Java JDK
You can double check how to do this by referring to the thread here How to set java_home on Windows 7?
But what have you tried so far?

Ant is unable to find a javac compiler

I am trying to build some binaries of an application. When i am trying to make the build, I am getting this:
BUILD FAILED
/home/.../ant-build.xml:84: Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK.
It is currently set to "/usr/lib/jvm/java-8-openjdk-amd64/jre"
The application requires java 7, and i have it installed but i had it along java 8. The build requires for tools.jar which is located in java 7 only, therefore after several attempts i uninstalled java 8. However, when I am trying make again, i get the same error, even though i don't have java8 installed at all!
I set the JAVA_HOME properly:
$ echo $JAVA_HOME
/usr/lib/jvm/java-7-openjdk-amd64/
I doubt i need the path but i set that one up just in case as well :
$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/jvm/java-7-openjdk-amd64/bin
I'm running out of ideas here :P any help would be appreciated.
Also something maybe important, I had to add the repo manually to get java-7 otherwise it wasnt able to locate the package. Thats when i got double jdk-s.
I guess you are calling the JAVAC command from any other source/tool like Jenkins/Bamboo/Teamcity. Make sure you have set the environment variable of that tool. usually it lies in the manage tool option.
I was facing same issue while using Jenkins.If you don't set up an environment variable in tool from which you are making a call it take your
"/usr/lib/jvm/java-8-openjdk-amd64/jre" so go and set the the env variable JAVA_HOME of you tools. attaching screen shot of Jenkins issue. Go to Manage Jenkins -->configure system --> environment variables and set you java_home path.
Cheers
I just encountered the same situation.
That is because JAVA_HOME is not correctly set in sudo environment.
I added export JAVA_HOME=/path/to in /root/.bashrc, and eventually it was built right.
It seems that you are using javac of java8 with JAVA_HOME or CLASS_PATH pointing to java7.
You can use which java to check that.
export JAVA_HOME=/lib/jvm/java-7-openjdk-amd64
export export ${PATH}=${JAVA_HOME}:/bin:${PATH}`

Not able to set JAVA_HOME variable in ubuntu 14.04 on manual installation

I've downloaded java jdk1.8.0.7.tar.gz file from the official website and unzipped it into my home directory. Now to set the $JAVA_HOME variable I used the follwing commands command nano .bashrc and then appending export $JAVA_HOME=/home/shivam/Java/jdk1.8.0.7 at the end of the file . But whenever I run the command sudo $CATALINA_HOME/bin/startup.sh I get an error message saying
Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
At least one of these environment variable is needed to run this program
I don't understand why it is unable to find the java path though I've installed tomcat and set its home variable the this way, which worked.
I wan't to install Java manually without using apt-get. Kindly guide .
You want to append the following to .bashrc:
JAVA_HOME=/home/shivam/Java/jdk1.8.0.7
Note the missing $ at the start.
Also remember that the file won't effect your current shell without sourceing it first.
Also, when running a command with sudo, you are running it as the root user, not as yourself. So the environment variable needs to be set for the root user, not yourself.
You can run sudo env | grep JAVA_HOME to see whether it is set for root.
Have you run .bashrc ?
source .bashrc
Try add the following 2 lines in your .bashrc file:
JAVA_HOME=/home/shivam/Java/jdk1.8.0.7/
export JAVA_HOME

jnetpcap library unable to build on ubuntu 12.04

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
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.
Check that running java -version displays the installed Java version.
Repeat with /usr/lib/jvm/java-6-sun/bin/java -version.

"JAVA_HOME points to an invalid Java installation issue" with service install command in elastic search

I want to use elastic search with my PHP application.
after running service install command , I am getting fallowing error.
C:\elasticsearch-0.90.10\bin>service install
JAVA_HOME points to an invalid Java installation (no java.exe found in "C:\Progr
am Files (x86)\Java\jdk1.7.0_25\bin"). Existing...
Open up and Look into the service.bat file:
It searches for:
%JAVA_HOME%\bin\java.exe
hence your %JAVA_HOME% should not include bin in it.
A workaround if you do not have privileges to set up the environmental variables:
open the service.bat file,
a) Remove the line:
if NOT DEFINED JAVA_HOME goto err
b) Replace %JAVA_HOME% with your java jdk path, something like: C:\Program Files\Java\jdk1.7.0_51
Note: This is just a workaround which works all the time.
from your error message we can see your JAVA_HOME points to
C:\Program Files (x86)\Java\jdk1.7.0_25\bin
while it should point to
C:\Program Files (x86)\Java\jdk1.7.0_25
I think the error message is fairly descriptive , you should look in this folder
is java.exe there ? If not then your JAVA_HOME environment variable to point to the correct installation
heres a page showing how to do that
https://confluence.atlassian.com/display/DOC/Setting+the+JAVA_HOME+Variable+in+Windows
1st hit on google.
Either JAVA_HOME points to the wrong location or you don't have Java installed. Check and see if there's an install of Java in the location specified.
Also note that the JAVA_HOME variable should point to the root of the Java install not the /bin folder. This is being added by the program you're executing.
To change the JAVA_HOME variable to test further use the following in the command prompt:
set JAVA_HOME=c:\xxxx
Once you've established the correct value to use this can be permanently changed in Control Panel>>System>>Advanced System Settings>>Advanced>>Environment Variables
set JAVA_HOME=C:\Program Files (x86)\Java
Above must fix the issue, I came across the same issue while installing the elastic search.
i gave a try by giving "bin" part of path but it did not work, so i just give the top folder "java" in path, it worked.
Just to add my own experience.
i was setting JAVA_HOME using tab autocompletion.
It ends up something like "C:\Program files...:" and it didn't work saying that it cannot find the java program. I solved typing the JAVA_HOME path in the set command without using tab completion. The problem was probably related to the " in the env variable

Categories

Resources