Cassandra: Unable to find java executable - java

I am starting to learn cassandra and downloaded the file from the Apache Cassandra. When I navigated through the bin folder of the apache-cassandra-2.2.1/bin and run the command cassandra it gives me the error saying Unable to find java executable. Check JAVA_HOME and PATH environment variables.
But at the same path when I hit java I am able to see the java is accessible there. What should I do to get rid of this? I am using Windows OS.
Edit:
I rather used Datastax windows installer and now I see no error in running cqlsh.

I was also facing the same problem. Actually, somewhere in installation scripts it adds "bin/java" to "$JAVA_HOME". In my case, java path was "/usr/bin/java" so I had to configure $JAVA_HOME=/user.
export JAVA_HOME=/usr/

Set JAVA_HOME:
Right click My Computer and select Properties.
On the Advanced tab, select Environment Variables, and then edit JAVA_HOME to point to where the JDK software is located, for example, C:\Program Files\Java\jdk1.6.0_02.
FROM:
http://docs.oracle.com/cd/E19182-01/820-7851/inst_cli_jdk_javahome_t/index.html

login with root because Cassandra will start with the root
readlink -f $(which java)
vi ~/.bashrc
source ~/.bashrc
please note: java version should be same on cluster nodes
BR// nitin.k

Related

How to run JMeter through CMD from jdk/bin directory?

I want to run JMeter test plans from a UNIX server where env variables for java is not set. Its a test server and I dont have access to set that. We have different JDK versions and all are sitting in directories. I need to run my JMeter TestPlans on this server. I went to JDK /bin folder and tired to execute the below command
$ {jmeter-path}/bin/jmeter -nt testplan.jmx -l testresult.jtl
but this says
./bin/java: not found
But if I do simple java -version it shows the version result.Is that something that JMeter needs specifically the java env variable set or it wont run ? I dont have permission to set and I want to run the testplan using the JDK/JRE from its directories. A help would be appreciated. Thanks in advance!
UPDATE:
I think I could work around this by editing the jmeter script file as suggested in the one of the comments. Since my requirement was running the JMeter from a specific server, I could achieve this by editing the JAVA_HOME variable value in the script.
JMeter looks for java executable in system PATH so you have 2 options:
Add bin folder of your JDK or JRE to PATH, something like:
PATH=$PATH:/location/of/your/jbk/bin && export PATH && {jmeter-path}/bin/jmeter -nt testplan.jmx -l testresult.jtl
Or if you have java in PATH just run ApacheJMeter.jar like:
java -jar {jmeter-path}/bin/ApacheJMeter.jar
You might also want to use jmeter.sh wrapper script instead of jmeter, it has some logic regarding java binary location
More information: Get Started With JMeter: Installation & Tests
The official JMeter Getting Started documentation says this:
To install a release build, simply unzip the zip/tar file into the directory where you want JMeter to be installed. Provided that you have a JRE/JDK correctly installed and the JAVA_HOME environment variable set, there is nothing more for you to do.
Based on the symptoms that you reported, I think that you have not set JAVA_HOME correctly. It should be set to an absolute path to your Java installation's top directory.

spark-class: line 71...No such file or directory

I've installed Spark 2.1.1 on Ubuntu and no matter what I do, it doesn't seem to agree with the java path. When I run "spark-submit --version" or "spark-shell" I get the following error:
/usr/local/spark/bin/spark-class: line 71: /usr/lib/jvm/java-8-openjdk-amd64/jre/bin//bin/java: No such file or directory
Now obviously the "/bin//bin/java" is problematic, but I'm not sure where to change the configuration. The spark-class file has the following lines:
if [ -n "${JAVA_HOME}" ]; then
RUNNER="${JAVA_HOME}/bin/java"
I was originally using a version of Spark meant for Hadoop 2.4 and when I changed it to "RUNNER="${JAVA_HOME}" it would either give me the error "[path] is a directory" or "[path] is not a directory." This was after also trying multiple path permutations in /etc/environment
What I now have in /etc/environment is:
JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/"
This is the current java setup that I have:
root#ubuntu:~# update-alternatives --config java
There is only one alternative in link group java (providing /usr/bin/java): /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
bashrc has the following:
export SPARK_HOME="/usr/local/spark"
export PATH="$PATH:$SPARK_HOME/bin"
Can anyone advise: 1) What files I need to change and 2) how I need to change them? Thanks in advance.
spark-class file is in the link, just in case:
http://vaughn-s.net/hadoop/spark-class
In the /etc/environment file replace
JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/
with
JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64/jre/
then execute
source /etc/environment
also RUNNER="${JAVA_HOME}/bin/java" should be kept as it is
Windows Environment:
Open Advanced system settings -> Environment Variables to set JAVA_HOME path, and the most common mistake is setting the path to JAVA folder:
JAVA_HOME: Directory-Name:\java
rather than setting it to JDK folder
JAVA_HOME: Directory-Name:\jdk
This is how it worked for me.

Setting JAVA_HOME variable

I try to set JAVA_HOME variable on an ubuntu server. I get the Java path with this command
which java
/usr/bin/java
I set the result in /etc/environment
JAVA_HOME="/usr/bin/java"
When I try to run a mvn command I get this error
Error: JAVA_HOME is not defined correctly.
We cannot execute /usr/bin/java/bin/java
You should not set JAVA_HOME to /usr/bin/java, because that's just a symbolic link to the java executable, which points to where the real executable is.
JAVA_HOME should point to the Java installation directory, and not to the java executable (or a link to the executable).
Find out where your Java installation directory is and then set JAVA_HOME to that directory (and not to the java executable). If you installed Java using Ubuntu's package management system, then the Java home directory is probably one of the subdirectories in /usr/lib/jvm.
Per the Oracle site:
export JAVA_HOME=jdk-install-location
export PATH=$JAVA_HOME/bin:$PATH
You can add these lines into your ~/.bash_profile (or ~/.bashrc), and then refresh using source ~/.bash_profile

Error while installing Elasticsearch on Windows

I have setup the Java path and I tried to run ElasticSearch on Windows 7. But I'm getting this error:
"no java.exe found on C:\Program Files\Java\jdk1.7.0_17\bin\".
I can run java & javac, they work fine.
How do I solve this issue?
So, I've kept hitting this problem and the solution is twofold. Like Udit said your Java_Home path should not include the bin folder (the reason being that the elastic search bat file seems to add on the bin folder manually, so if you add it the path would be bin\bin)
The second thing to check for is spaces in your path. If Java is installed to C:\Program Files then use C:\Progra~1 and if it's in C:\Program Files (x86) then use C:\Progra~2.
This should mean your Java_Home is set to something like C:\Progra~1\Java\jre7
To Verify this works open a command prompt and type %Java_Home%\bin\java and press return, you should then see all the command line parameters for Java listed. If you get this far you should be able to just run elasticsearch.bat
JAVA_HOME is the environment variable that points to Java installation directory.
Example: If u have installed Java in 32 bit windows 7 operating system, it would have installed in
C:/Program Files/Java/jdkx.x.x
This path should be put as JAVA_HOME. Probably you have set the path till bin directory i.e. C:/Program Files/Java/jdkx.x.x/bin
that is why it cannot find the java.exe.

"java -version" not working in command prompt

I downloaded this Java JDK and installed it.
But when I go to the command prompt to check the version, it says it's not recognized.
Is anyone else experiencing this issue with the latest Java?
I might not have installed the right version. I need the java that works with grails
C:\>java
'java' is not recognized as an internal or external command,
operable program or batch file.
C:\>java -version
'java' is not recognized as an internal or external command,
operable program or batch file.
C:\>
when i do a search on my computer for java, it does not find anything
Windows 2k8 R2 server-
For both java [-option] or %JAVA_HOME% to work in the command line you need the following:
In Control Panel->System and Security->System->Advanced system setting->Advanced->Environment Variables->System Variables
Edit the Path variable and add a ";" after the last value and add the the path to the Java bin directory:
e.g.- C:\Progra~2\Java\jre6\bin\
Add the JAVA_HOME Variable with the value set to the path for the java executable:
e.g.- C:\Progra~2\Java\jre6\bin\java.exe
Press simultaneously the "windows" and "pause" buttons on your keyboard, this will bring up the System Preferences dialog.
In the Advanced tab, find Environment Variables.
Then, in the User (upper) section, create or update the following two variables :
JAVA_HOME = where you put your JDK, eg. C:/Java/SDK
PATH = %JAVA_HOME%/bin
Close the dialogs.
Then, in a new command-line console, try "javac -version" and see if it's detected.
It's important that you use a new console, because environment variables are read only when the console is launched.
Java is typically installed (on Windows) as C:\Program Files\Java\jdk<version>
That installation directory has a subdirectory bin which you need to append to your PATH environment variable via the control panel. Then, the commands like java, javac etc. will be available on the command line.
BTW, the same is true for Grails.
Is the -version flag not recognized, or is the "java" command not recognized? One way to test this is just to type 'java' by itself and run it and see what happens.
If the command is not recognized, make sure that the JDK's install path is in your windows PATH. If not, you won't be able to use any of the java executables from the command prompt. Here's another link that may help out.
You need to manually add the path to javac.exe and java.exe to your operating system path. The Java installation program doesn't do that for you.
You most likely don't have java.exe in your system's PATH variable.
For Linux:
check $PATH and $JAVA_HOME. You can configure it in /etc/environment
From console you can check it like:
$ echo $PATH
For Windows:
My Computer -> Properties -> Advanced -> Environment Variables
Check there PATH.
From console you can check it like:
echo %PATH%
You should have a Java icon in Windows Control Panel. Locate the Java tab and click the View button. That will show you the path to the Java executables.
Last but not least, make sure you have restarted the computer so changes in the PATH variable can take effect.
You installed the JDK. Isn't java.exe part of the JRE? Do you have that installed?
Maybe your system variables in the environment variables are not set properly. Follow the steps in the link below. Finally, make sure the path component in system variables has only one JDK path. Delete other JDK paths that you won't use.
https://docs.oracle.com/javase/tutorial/essential/environment/paths.html
You might have installed a previous or older version of Java so you can just uninstall it and directly download JDK from Java JDK
I was also facing the same issue but when I downloaded and installed the latest version the issue was resolved.
Also uninstall any other Java versions which may be present in the program files.
To get to know other versions which may be present in your computer use Windows File Explorer to go to:
Files > Windows C > Program Files > Java
All the JDK and JRE you have will be listed there. Uninstall any other Java versions other than what you installed. And then make sure you have set the path variable of the JDK.
For me, it was incorrect line in the PATH
(1) Check PATH: Type "Edit System Environment Variables" on the search -> System Properties -> Advance -> Environment Variables -> System variables -> Path
(2) On the list, mine was C:\Program Files (x86)\Common Files\Oracle\Java\javapath so I just add \ at the end (the exe files in the javapath folder)
OS: Windows 10 64 bit
IF you set the PATH and it's not showing up in cmd when you run %PATH%, try restarting your computer.

Categories