Ok, so this is actually quite a long story, but i'll try and keep it pretty short. So I'm trying to get the WebOS SDK working on Windows using Cygwin. Well, it wasn't working. It kept complaining that i was using a 32 bit version of java instead of 64 bit. the explenation for that problem is pretty easy to figure out. my PATH variable was set wrong and was pointing to my 32 bit installation of Java. Simple solution YOU'D THINK. apparantly not. for some reason, despite my best efforts, i cannot get the 64 bit version of java written into the PATH variable. The problem:
Cygwin doesn't like spaces in the Path variable, even though the path variable is littered with spaces, it won't accept it when i add my own space. After a lot of googling, i've found multiple accurances of this problem, and multiple solutions. but none of them seem to work. i always get exactly the same error:
bash: /usr/local/bin:/usr/bin:/cygdrive/c/Program: No such file or directory
The error is pretty self explanetary, basically its not reading anything past the first space, and i have no such directory as C:/Program so it spits out an error, my question is how do i get it to except a space, because changing the name of the directory is not an option, too many things depend on it. heres what i've tried so far:
$PATH=$PATH:C:\PROGRA~1\Java\jre6
$PATH=$PATH:"'pwd'" (while in java directory)
$PATH=$PATH:/cygdrive/c/Program Files/Java/jre6/bin (hay, i had to try)
$PATH=$PATH:/cygdrive/c/"Program Files"/Java/jre6/bin
$PATH=$PATH:/cygdrive/c/Program\ Files/Java/jre6/bin (escape character was rumored to work
$PATH=$PATH:'/cygdrive/c/Program Files/Java/jre6/bin'
$PATH=$PATH:"`/cygdrive/c/Program Files/Java/jre6/bin`"
and i think that was it, if anyone knows how to actually do it properly (or improperly but working for all i care) it would be greatly appreciated
Thanks
--
Chris
You also have the option of using the cygpath tool to help. Cygpath can be used to convert from a Window's path to a Unix path, but that doesn't directly handle spaces, so you need to do a two step process, first eliminate the spaces by converting to a DOS (short) path name, then convert to a Unix style path:
PATH=$(cygpath -u $(cygpath -m -s "C:\Program Files\Java\jre6\bin")):${PATH}
PATH=$(cygpath -u $(cygpath -m -s "C:\Program Files (x86)\HP webOS\PDK\bin")):${PATH}
PATH=$(cygpath -u $(cygpath -m -s "C:\Program Files (x86)\HP webOS\SDK\bin")):${PATH}
PATH=$(cygpath -u $(cygpath -m -s "C:\Program Files (x86)\HP webOS\SDK\bin\novacom")):${PATH}
The end result will be something like (short names may differ slightly):
/cygdrive/c/PROGRA~3/HPWEBO~1/SDK/bin/novacom:/cygdrive/c/PROGRA~3/HPWEBO~1/SDK/bin:/cygdrive/c/PROGRA~3/HPWEBO~1/PDK/bin:/cygdrive/c/PROGRA~1/Java/jre6/bin:....other path elements....
One thing to keep in mind when using this, cygpath generates an error if the provided path actually does not exist because it can not create the short path for a non-existent path.
What is nice about this approach is that if you set Windows environment variables (like for example JAVA_HOME) then you can use that environment variable in the convert operation inside the .bash_profile, since all Windows environment variables are visible when the profile is being loaded. So if you had in the Windows environment
JAVA_HOME=C:\Program Files\Java\jre
then the cygpath command can be
$(cygpath -u $(cygpath -m -s "${JAVA_HOME}\bin"))
which means you only ever need to update via the Windows settings if the java install changes.
In .bash_profile:
PATH=/cygdrive/c/Program\ Files/Java/jre6/bin/:${PATH}
PATH=${PATH}:/cygdrive/c/Program\ Files\ \(x86\)/HP\ webOS/PDK/bin
PATH=${PATH}:/cygdrive/c/Program\ Files\ \(x86\)/HP\ webOS/SDK/bin
PATH=${PATH}:/cygdrive/c/Program\ Files\ \(x86\)/HP\ webOS/SDK/bin/novacom
Adds the paths to your .bash_profile and both java and the webOS SDK tools should be available.
Related
I am using centOS 6.10
ls /usr/lib/jvm
O/P:
java-1.6.0-openjdk-1.6.0.41.X86_64
java-1.7.0-openjdk-1.7.0.181.X86_64
java-1.7.0-openjdk-1.7.0.261.X86_64
java -version
O/P:
java version "1.7.0_181"
while checking for jps I am getting like this,
jps
O/P:
Error: could not find libjava.so
Error: could not find Java SE Runtime Environment.
My bashrc file be like,
export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.261.X86_64/
export HADOOP_INSTALL=/usr/local/hadoop
export PATH=$PATH:$HADOOP_INSTALL/bin
I dont know why this error is popping. I am getting frustrated because of this I am searching the solution for more than 3 days. Any help would be much appreciated.
Thanks in advance!!
I found java-related processes are sometimes quirky when it comes to libraries.
First identify the path for libjava.so and confirm the lib and executable are the same, one of 32- or 64-bit:
file /path/to/libjava.so /other/path/to/jps
Next, for any process like jps as an example, run this:
ldd /some/path/jps
The runtime link-editor should list an abs path for each lib referenced by the executable, or an error if not found. When there is an error, the lib is missing or exists in a directory that's not within the link-editor's search path. For normal processes, setting LD_LIBRARY_PATH usually works, but java stuff is too often quirky. Try experimenting with cmd-lines or a script, eg:
#!/bin/bash
LD_LIBRARY_PATH=/usr/local/lib64 /full/path/to/jps $*
(replace /usr/local/lib64 with the leading path to libjava.so).
Note that an independent "export KEY=val" is not required, and would add info into the environ and gets inherited by any process that follows; as shown, the shell sets KEY=val only for the cmd-line.
Some java-related quirks are processes that either clear the environ or reset stuff like LD_LIBRARY_PATH within their own child process(es), or call execve() with a NULL envp, and the child then fails as you describe. In that case you may have to resort to moving libs to a specific dir, or modify a java-related config file which lists lib dirs.
Sometimes quick answers can be found with strace, made easier when limiting the output, eg:
strace -f -e execve,open jps
I installed JDK on windows 10, 64bit, followed the documentation instructions.. CMD does not recognize javadoc command. What I tried:
-copied the path of the "bin" folder from Java and in cmd I wrote the command:
set path = "full_path_to_java_sdk_bin_folder"
I saw this on youtube and it worked for the guy, my cmd still did not recognize javadoc command -I set the PATH in system variables from control panel->system->advanced->environment variables and made sure that there are is no other bin folder...
Didn't find any other tips online...
The usual approach for Java development is to set a JAVA_HOME environment variable, and use that to update the PATH (for one thing, it makes it much easier to support multiple versions of Java). Also of note is that Windows puts the quotes oddly on the command line (oddly compared to every other platform that is) and if your path contains spaces you need to quote it correctly. Like,
set "JAVA_HOME=<full_path_to_jdk>"
set "PATH=%JAVA_HOME%\bin;%PATH%"
I'm not sure where I went wrong, but I used nano to edit my bash_profile to install JavaSDK on my Mac a few days ago. I have been doing everything in Eclipse, so I haven't had occasion to visit the command line for a few days...until today.
Nothing works. No ls, no nano, no vim...nothing. I tried to type:
-bash: nano: command not found
-bash: ls: command not found
defaults write com.apple.finder.AppleShowAllFiles YES to unhide system files so I can figure out where my .bash_profile is and I get this:
-bash: defaults: command not found
I'm able to find command line solutions that look promising, but I can't get any commands to be recognized. Any helpful hints would be greatly appreciated.
UPDATE:
I've attempted to implement solutions I've found on StackOverflow and elsewhere, yet I'm still finding commands that were previously working are no longer doing so. When I make changes, I log out and back in. Rebooting doesn't seem to do the trick, either.
echo $PATH returns the following:
/Library/Frameworks/Python.framework/Versions/2.7/bin:/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home/bin:/usr/local/sbin:/usr/sbin:/usr/bin:/root/bin:/usr/local/bin
Here's my .bash_profile:
#Setting PATH for Python 2.7
export RBENV_ROOT=/usr/local/var/rbenv
#Java setup
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home
export PATH=/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home/bin
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
# RUBY FIX?
# PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}:/usr/local/sbin:/usr/sbin:/usr/bin:/root/bin:/usr/local/bin"
export PATH
Are there any other places I should be looking? What turned out to be a minor issue a few days ago is turning into a major one, as I can't get any work done.
Use /usr/bin/nano (not just nano because your PATH variable is messed up) to edit your .bash_profile again.
Remove the line:
export PATH=/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home/bin
As well as the line:
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}:/usr/local/sbin:/usr/sbin:/usr/bin:/root/bin:/usr/local/bin"
First, save this, log out, log in, and make sure that you have all your commands back as you know them.
Then check if you have python and java available. You should not need to change the PATH at all when you have installed Java, and I believe not when you have installed python either. The installation of the Oracle JDK automatically adds java to your existing path. At most, you should set the JAVA_HOME.
I'm writing an application that leverages jsvc to start up a Java service as a daemon. I need to use something like jsvc because my application utilizes ports under 1024 and yet I'd really like to not run it as root so that created files are owned by another user. I'd also like to keep dependencies and configuration to a minimum so that all the client needs is a JVM and the jsvc binary installed.
However, it seems that jsvc has one major catch; it can't detect the home folder of Java on a given Unix operating system, which is quite frustrating:
$ ./startup.sh
Cannot locate Java home
I have been able to work around the issue on Ubuntu at least by manually setting the JVM home directory:
jsvc ... -home /usr/lib/jvm/default-java/ ...
Is there any way to determine the Java home directory dynamically from a Bash script so I can make this work across most Unixes/Linuxes? I'd be able to sleep much better at night doing something like:
JAVA_HOME="$( ... )"
jsvc ... -home "$JAVA_HOME" ...
...rather than hard-coding for each individual operating system. Is there a way that, given a java binary, I can find the home directory of its JVM/JRE?
Not sure if this works across *nixes, but found this solution:
JAVA_HOME="$( readlink -f "$( which java )" | sed "s:bin/.*$::" )"
I've tested it on Ubuntu and it works, however it does not work for OSX.
My solution was compiling the native linux source as the main jsvc page says in
http://commons.apache.org/proper/commons-daemon//jsvc.html
Here is my step by step procedure
Download www.fightrice.com/mirrors/apache/commons/daemon/source/commons-daemon-1.0.13-src.tar.gz
Once you extract the file then go to ...../commons-daemon-1.0.13-src/src/native/unix
in terminal as a root do the following:
$ support/buildconf.sh
$ ./configure --with-java=/usr/lib/jvm/default-java
$ make
test generated jsvc binary app
$ ./jsvc -help
It works! cleanly.
Use dirname and which commands to find Java's bin directory:
echo `dirname \`which java\``
JAVA_HOME=`dirname \`which java\``
... Only works if Java is already on the $PATH.
One other way is :
type -p java
Expect this to return the correct JAVA installation folder.
I'm using gvim as my main 'IDE' on windows 7 and I would like to use ctags to navigate through the code. I've downloaded it and ran based on this tutorial: http://www.techrepublic.com/article/configure-vi-for-java-application-development/5054618
ctags -f ~/.tags -R ~/myprojects/src $JAVA_HOME/src
I've then setup my vimrc with...
set tags=~/.tags
However when I do Ctrl+] on a keyword, it says it can not find the file which the tag is defined in. Shows the correct path except it misses out c:\ from the start so vim can't load it.
How can get it to give me the correct path?
I'm using the latest version of gvim and ctags.
Thanks
FWITW, I'm not entirely sold on the concept of keeping my tags in one location.
This part of the command call:
-f ~/.tags
Nor would I hard path to my current project. This part:
-R ~/myprojects/src
BTW, Windows doesn't have ~ so I don't think either of those would work (not sure if Vim will find ~, i.e. "home").
If I were you, I would cut my teeth on the simplest method until you get more comfortable with the Vim methods and ideals.
Easiest method:
Always let Vim know the "Current Directory" (making the assumption that you are not launching Vim via the command prompt). When you open a file always set the current directory by issuing the following command from normal mode:
:cd %:p:h
Generate a tag file in the current directory with the following command (from normal mode).
:!ctags -R .
Happy jumping.