Cygwin failing to find Java - hadoop

I'm currently trying to configure a standalone Hadoop node on a new computer (for my own learning purposes) but when I try to find the root of my java installation using $which java
as per this question
root of java installation
I get the following error
Me#myhouse /cygdrive/c/Program Files (x86)
$ which java
which: no java in (/usr/local/bin:/usr/bin:/cygdrive/c/Windows/system32:/cygdrive
/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32
/WindowsPowerShell/v1.0:/cygdrive/c/Program Files (x86)/ATI Technologies/ATI.ACE/Core-Static)
I get the exact same error message at the top level of my C: drive.
I know that Java is there - I just installed it! Can anyone explain what I have done wrong?

Your command just checks if java is found in the common paths from cygwin
So in cygwin you need to add the java path to the paths: export JAVA_HOME="/cygdrive/c/Program\ Files/Java/jre1.8.0_102" export PATH="$PATH:$JAVA_HOME/bin"

Related

Hadoop Installation: No such file while run hadoop format

I've checked answers on stackoverflow, no solutions work for my case.
Command:
bin/hadoop namenode -format
Error Message:
/bin/java: No such file or directory1.7.0_09/
/bin/java: No such file or directory1.7.0_09/
/bin/java: cannot execute: No such file or directory
Relevant change in hadoop_env.sh
# The java implementation to use. Required.
export JAVA_HOME=/usr/local/jdk1.7.0_09/
I use soft-link by
ln -s "c:\Program Files\java\jdk1.7.0_09" /usr/local/jdk1.7.0_09
Java HOME:
C:\Program Files\Java\jdk1.7.0_09
Path :
C:\cygwin64\bin;C:\cygwin64\usr\sbin
If any one has clues, please feel free to point it out. Thanks.
#xhudik #s.singh Finally! There is a problem when modifying hadoop_env.sh in Windows. I've fixed the problem with dos2unix command to eliminate dos style character.
If dos2unix command can't be found in cygwin, re-download cygwin and update it.
Please follow the link here:
https://superuser.com/questions/612435/cygwin-dos2unix-command-not-found
The command is
dos2unix hadoop_env.sh
Then everything is all set. Hope my experience would help others.
Thanks for s.singh and xhudik's help.
there is no java. Are you sure that your java binaries (./java , ./javac...) are in the specified directories? Maybe ln is a problem. Java also doesn't like " " in directory name (c:\program files) ...
You need to correctly place java distribution and then define JAVA_HOME variable. You can test it by:
$JAVA_HOME/bin/java -version
Set your java home like this:
JAVA_HOME=C:/Program Files/java/jdk1.7.0_09 in hadoop_env.sh
also you need to set Java Path in environment variable for java.
If still getting issue, then please let us know.
For learning and best practice on hadoop, try using cloudera version or Hortonworks version of hadoop . You can download their windows version. Please check link:
hortonworks.
cloudera
Or you can use IBM Smart Cloud enterprise. IBM is giving free access for students and learning.

How to use different java versions for different programs?

This may be common in web but may be I am not getting what to search exactly. Actually I am having different versions of java on my ubuntu server having java 1.5 as default. One of my program need java 1.6 and even if I perform following in the shell script executing that program
export JAVA_HOME=/path/to/jdk6
I dont get any success.What I learnt is I could see current java version using
java -version
This only get change when I changes the alternative using:
sudo update-alternatives --config java
Please tell me how can I change it in the shell script which in turn calls the java program requiring java6 having java 5 as default only.
Thanks!!!
You need to update the PATH as well:
JAVA_HOME=/path/to/jdk6
export JAVA_HOME
PATH=${JAVA_HOME}/bin:${PATH}
export PATH

How can I set my Cygwin PATH to find postgresql header and library path?

I am on Windows 7 and installed Cygwin and PostgresSql-8.4 on it. I have an open-source application written in C that requires to be build and for that, I am using Cygwin.
My problem is with setting the path for PostgreSql in Cygwin. As per the instruction that came with open-source, the build requires me to export path to postgreSql header and library path as follows:
export ENV_PG_INC_PATH=/usr/include/pgsql
export ENV_PG_LIB_PATH=/usr/lib/pgsql
I tried to export the same path in Windows using Cygwin as follows:
export ENV_PG_INC_PATH=$ENV_PG_INC_PATH:"/cygdrive/C/Program Files (x86)/PostgreSQL/8.4/include"
export ENV_PG_LIB_PATH=$ENV_PG_LIB_PATH:"/cygdrive/C/Program Files (x86)/PostgreSQL/8.4/lib"
But this doesn't seems to be working as when I try to access the dll's or any exe's inside these folders, it throws the error as follows:
-bash: _int.dll: command not found
I don't know what is it that I am doing wrong as I am new to Cygwin. Any help would be appreciated.
Thanks in advance.
You have to escape all spaces in file paths:
export ENV_PG_LIB_PATH=$ENV_PG_LIB_PATH:"/cygdrive/C/Program\ Files\ (x86)/PostgreSQL/8.4/lib"

javaerror while installing the hive

I want to install Hive and hadoop on my ubuntu.I followed this article all of things seems good but the end step when I write this command an error about Java appear like this:
/home/babak/Downloads/hadoop/bin/../bin hadoop: row 258:/usr/lib/j2sdk1.5-sun/bin/java: file or Folder not found
what should i do to solve this problem?
You need to find where on your machine java is installed:
which java
and then from there follow any symlinks or wrapper scripts to the actual location of the java executable.
An easier way to do this is to run the file indexer and then locate the file (here i use the jps executable, which is in the same folder as java:
#> sudo updatedb
#> locate jps
Whatever you get back, trim off the bin/jps suffix, and that's your JAVA_HOME value. If you can't find the executable, than you'll need to install java
Hadoop requires Java version 1.6 or higher. It seems like hadoop is looking for Java 1.5. Also, make sure the variable HADOOP_HOME is set in file /conf/hadoop-env.sh
I have a line like the following in mine:
export JAVA_HOME=/usr/lib/jvm/java-6-sun/

How to install yui compressor in CentOs

I know this is going to sound like a noob question, but I'm new to using linux, I was trying to find out how to install yui-compressor in CentOS, but I haven't been able to find it using google.
I have already done this:
wget http://yui.zenfs.com/releases/yuicompressor/yuicompressor-2.4.6.zip
unzip yuicompressor-2.4.6.zip
# mv yuicompressor-2.4.6/build/yuicompressor-2.4.6.jar /usr/share/yui-compressor/yui-compressor.jar
I've also created a file in /usr/bin called yui-compressor that has:
#!/bin/sh
YUI_JAR=/usr/share/yui-compressor/yui-compressor.jar
I dont know what else to do. (I don't even know if its already installed).
Can someone please help me with the following:
If its installed, please tell me.
If not. Tell me what else do I need to do.
Thank you.
At the most basic level, you will want to update your /usr/bin/yui-compressor script to look something like this:
#!/bin/sh
YUI_JAR=/usr/share/yui-compressor/yui-compressor.jar
java -jar $YUI_JAR "$*"
Ensure that you have a Java runtime installed.
As Jordan mentioned, make sure you have Java installed. Try java -version to see if the JDK info shows up. If not try, which java -- on CentOS it should be in /usr/bin/java if are using the RPM installed version.
If it doesn't show up, use: yum install java-1.6.0-openjdk which should install the JDK and any other required java libs (do this with sudo or as root user). Just make sure you don't already have another JDK installed or you could run into problems later (try rpm -qa | grep java to see what's installed via RPM).
Then you should be able to call the yuicompressor directly with a statement like:
/usr/bin/java -jar /usr/share/yui-compressor/yui-compressor.jar --help
If you get the help output, you probably are ok. You can then use it on a file with a statement like:
/usr/bin/java -jar /usr/share/yui-compressor/yui-compressor.jar /path/to/source/file >> /path/to/exportfile.js
(obviously change the filename paths.) There are a number of options you can use, but that should get you started. I'm using this on CentOS with a build script that loops through various files and creates optimized bundled files and it works well.
You may also want to check out the build script and instructions at: http://html5boilerplate.com/ which uses yui-compressor and is the method I would eventually like to go with.

Resources