Cannot find jdeps command (Mac) - java

I'm using Java 8 update 45 on my mac.
I've tried to use 'jdeps' command, but my mac keeps showing "command not found" message. Weird thing is that other command in the bin folder like 'java', 'javac' perfectly works. Only 'jdeps' command is not working.
How can I use jdeps command? Is there any condition to use this command?

It's definitely there in the version I have on Mac:
/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/bin
The crux the it seems to be that some of the things in the above don't get the magic mentioned below:
http://lists.apple.com/archives/java-dev/2015/Nov/msg00009.html
When the JAVA_HOME environment variable is set Mac OS X does some magic
But the problem is not all the commands are covered, and some are missing from newer JDKs
The links don't appear in:
$ ls -l `which java`
lrwxr-xr-x 1 root wheel 74 1 Jul 2014 /usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk_version/Contents/Home
export PATH=${PATH}:${JAVA_HOME}/bin

Related

Java in usr/bin/java missing

I can locate java in my machine in etc/alternatives/java(link to executable file to /usr/local/java/jdk1.8.0_201/bin/java where I can see executable java file).
Kindly please help me to move this java file to usr/bin/java directory.
As lot of dependant applications are failing to run because of this.
Thanks
Pritam
This is because there are some 32-bit libraries missing in your Ubuntu 64-bit. Run:
apt-get install libc6-i386
This is the setup you are looking for. I am surprised that the install process didn't do this for you. You need the Unix ln -s command.
$ file /usr/bin/java
/usr/bin/java: symbolic link to /etc/alternatives/java
$ ls -l /usr/bin/java
lrwxrwxrwx 1 root root 22 Apr 18 2018 /usr/bin/java -> /etc/alternatives/java

which java command should return custom java installation path

I have jdk installed under "/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java"
When i do a "which java", it returns "/usr/bin/java"
But, I want which java to return /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java, instead of /usr/java/bin
How can this be done? and what is happening behind the scenes?
It may be that /usr/bin/java is a symbolic link.
Try
ls -l `which java`
This will run an ls -l on the output of 'which java', hopefully giving you the full path pointed to by the link.
/usr/bin/java is a symlink:
/usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java
If you use:
/usr/libexec/java_home -v
You can confirm whether or not it's using 1.6.0:
/Library/Java/JavaVirtualMachines/jdk1.6.0.jdk/Contents/Home

JAVA_HOME and PATH are set but java -version still shows the old one

I am using Linux Mint Cinnamon 14. I have set the $JAVA_HOME and $PATH environment variables in ~/.profile as follows:
export JAVA_HOME=/home/aqeel/development/jdk/jdk1.6.0_35
export PATH=/home/aqeel/development/jdk/jdk1.6.0_35/bin:$PATH
I then did source ~/.profile to make the proper changes.
When I execute java -version command to check the active java version, it shows the default (already installed open-jdk) java version. How can I override the default open-jdk with the one I downloaded?
UPDATE:
which java says /usr/bin/java
$JAVA_HOME/bin/java -version says 'Permission Denied'
sudo $JAVA_HOME/bin/java -version (asks for password, then) says Command not found
but cd $JAVA_HOME/bin, and ls shows that it is right directory.
While it looks like your setup is correct, there are a few things to check:
The output of env - specifically PATH.
command -v java tells you what?
Is there a java executable in $JAVA_HOME\bin and does it have the execute bit set? If not chmod a+x java it.
I trust you have source'd your .profile after adding/changing the JAVA_HOME and PATH?
Also, you can help yourself in future maintenance of your JDK installation by writing this instead:
export JAVA_HOME=/home/aqeel/development/jdk/jdk1.6.0_35
export PATH=$JAVA_HOME/bin:$PATH
Then you only need to update one env variable when you setup the JDK installation.
Finally, you may need to run hash -r to clear the Bash program cache. Other shells may need a similar command.
Cheers,
update-java-alternatives
The java executable is not found with your JAVA_HOME, it only depends on your PATH.
update-java-alternatives is a good way to manage it for the entire system is through:
update-java-alternatives -l
Sample output:
java-7-oracle 1 /usr/lib/jvm/java-7-oracle
java-8-oracle 2 /usr/lib/jvm/java-8-oracle
Choose one of the alternatives:
sudo update-java-alternatives -s java-7-oracle
Like update-alternatives, it works through symlink management. The advantage is that is manages symlinks to all the Java utilities at once: javac, java, javap, etc.
I am yet to see a JAVA_HOME effect on the JDK. So far, I have only seen it used in third-party tools, e.g. Maven.
If you want to use JDKs downloaded from Oracle's site, what worked for me (using Mint) is using update-alternatives:
I downloaded the JDK and extracted it just anywhere, for example in /home/aqeel/development/jdk/jdk1.6.0_35
I ran:
sudo update-alternatives --install /usr/bin/java java /home/aqeel/development/jdk/jdk1.6.0_35/bin/java 1
Now you can execute sudo update-alternatives --config java and choose your java version.
This doesn't set the JAVA_HOME variable, which I wanted configured, so I just added it to my ~/.bashrc, including an export JAVA_HOME="/home/aqeel/development/jdk/jdk1.6.0_35" statement
Now, I had two JDKs downloaded (let's say the second has been extracted to /home/aqeel/development/jdk/jdk-10.0.1).
How can we change the JAVA_HOME dynamically based on the current java being used?
My solution is not very elegant, I'm pretty sure there are better options out there, but anyway:
To change the JAVA_HOME dynamically based on the chosen java alternative, I added this snippet to the ~/.bashrc:
export JAVA_HOME=$(update-alternatives --query java | grep Value: | awk -F'Value: ' '{print $2}' | awk -F'/bin/java' '{print $1}')
Finally (this is out of the scope) if you have to change the java version constantly, you might want to consider:
Adding an alias to your ~./bash_aliases:
alias change-java="sudo update-alternatives --config java"
(You might have to create the file and maybe uncomment the section related to this in ~/.bashrc)
$JAVA_HOME/bin/java -version says 'Permission Denied'
If you cannot access or run code, it which be ignored if added to your path. You need to make it accessible and runnable or get a copy of your own.
Do an
ls -ld $JAVA_HOME $JAVA_HOME/bin $JAVA_HOME/bin/java
to see why you cannot access or run this program,.
When it searches for java it looks from left to right in path entries which are separated by : so you need to add the path of latest jdk/bin directory before /usr/bin, so when it searches it'll find the latest one and stop searching further.
i.e. PATH=/usr/java/jdk_1.8/bin:/usr/bin:..... and so on.
then initialize user profile using command: source ~/.bash_profile
and check with: [which java]
you'll get the right one.
check available Java versions on your Linux system by using update-alternatives command:
$ sudo update-alternatives --display java
Now that there are suitable candidates to change to, you can switch the default Java version among available Java JREs by running the following command:
$ sudo update-alternatives --config java
When prompted, select the Java version you would like to use.1 or 2 or 3 or etc..
Now you can verify the default Java version changed as follows.
$ java -version
Try this:
export JAVA_HOME=put_here_your_java_home_path
type export PATH=$JAVA_HOME/bin:$PATH (ensure that $JAVA_HOME is the first element in PATH)
try java -version
Reason: there could be other PATH elements point to alternative java home. If you put first your preferred JAVA_HOME, the system will use this one.
There is an easy way, just remove the symbolic link from "/usr/bin". It will work.
Updating the ~/.profile or ~/.bash_profile does not work sometimes. I just deleted JDK 6 and sourced .bash_profile.
Try running this:
sudo rm -rd jdk1.6.0_* #it may not let you delete without sudo
Then, modify/add your JAVA_HOME and PATH variables.
source ~/.bash_profile #assuming you've updated $JAVA_HOME and $PATH
In Linux Mint 18 Cinnamon be sure to check /etc/profile.d/jdk_home.sh I renamed this file to jdk_home.sh.old and now my path does not keep getting overridden and I can call java -version and see Java 9 as expected. Even though I correctly selected Java 9 in update-aternatives --config java this jdk_home.sh file kept overriding the $PATH on boot-up.

"Error: JAVA_HOME is not defined correctly." in building Jikes rvm

When I built the Jikes RVM on Ubuntu, I got this error. Any idea?
bin/buildit localhost production
---> Config: production
/bin/bash --login -c '/bin/bash --login -c " cd /home/jack/Programs/jikesrvm-3.1.2 && export JAVA_HOME=/opt/jdk1.6.0 && ant very-clean -Dhost.name=ia32-linux && ant check-components-properties -Dhost.name=ia32-linux -Dtarget.name=ia32-linux -Dcomponents.cache.dir=/home/jack/.buildit_components_cache && ant -Dtarget.name=ia32-linux -Dconfig.name=production -Dhg.revision= -Dhost.name=ia32-linux -Dcomponents.cache.dir=/home/jack/.buildit_components_cache "'
Error: JAVA_HOME is not defined correctly.
We cannot execute /opt/jdk1.6.0/bin/java
Wed Jun 13 12:23:37 EDT 2012
===================== Summary =====================
Local : /home/jack/Programs/jikesrvm-3.1.2
Build : ubuntu:/home/jack/Programs/jikesrvm-3.1.2
Target : ubuntu:/home/jack/Programs/jikesrvm-3.1.2
Start : Wed Jun 13 12:23:37 EDT 2012
Config : production [FAILED Wed Jun 13 12:23:37 EDT 2012]
===================================================
OS:
Linux ubuntu 2.6.32-24-generic #39-Ubuntu SMP Wed Jul 28 06:07:29 UTC 2010 i686 GNU/Linux
Environmental Variables:
PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/lib/jvm/java-6-sun-1.6.0.22/bin<
JAVA_HOME
/usr/lib/jvm/java-6-sun-1.6.0.22
I checked the java in the JAVA_HOME/bin directory, it works.
No matter how I change the environmental variables, the error kept complaining
"We cannot execute /opt/jdk1.6.0/bin/java".
It seems that I didn't modify the right "position".
run this command:
find . -exec grep "jdk1.6.0" {} \;
To find out which file is setting JAVA_HOME to that path.
While you build jikes you can either build it using ant or using the command you are using.
If the JAVA_HOME problem is causing trouble use
bin/buildit localhost production -j"path to your jvm directory"
-This is present in "/usr/bin/jvm".
Another method: There is bin/buildit.base_config in which path for JAVA_HOME is specifically mentioned. So under "# Default JAVA_HOME values" you can modify appropriate location, for example,
global.javahome.ppc32-linux=/usr/lib/jvm/java-6-sun-1.6.0.26
global.javahome.ppc64-linux=/usr/lib/jvm/java-6-sun-1.6.0.26
global.javahome.ia32-linux=/usr/lib/jvm/java-6-sun-1.6.0.26
global.javahome.x86_64-linux=/usr/lib/jvm/java-6-sun-1.6.0.26
You can chose which you want to use. If not familiar with your architecture, modify all and now you can build without having to worry about your java path to be mentioned explicitly.
For more detailed information check this blog
I have also written a small article on how one can start to fiddle with Jikes
It's JRE but not JDK. Install JDK and make JAVA_HOME pointing to it.
You might get this error due to couple of reasons. To fix this quickly please follow below steps,
First find the java location. To get a list of your installed Java platforms, run the following command from the terminal:
$ sudo update-alternatives --config java
Now set JAVA_HOME and PATH,
$ export JAVA_HOME=<java_home>
$ export PATH=$JAVA_HOME/jre/bin:$PATH
Create the symlink
$ sudo ln -s <java_home>/jre <java_symlink_path>
When we take your case as a example :
$ sudo ln -s /usr/lib/jvm/java-6-sun-1.6.0.22/jre /opt/jdk1.6.0
Above command will create the symlink location where the system is trying to find in your issue.
Finally do the try your app.

ZeroMQ Java Installation Problem

I'm trying to install ZeroMQ's Java library but I've been having problem. First error was ./configure complained about JAVA_HOME which everything seemed to be fine but I couldn't manage to solve it but I've found a particular solution in ZeroMQ's chat logs.
The suggested solution was;
JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Home" ./configure
However it doesn't work for me. The error message I've been receiving is
checking for jni.h in /Library/Java/Home/include... configure: error: cannot find jni.h in /Library/Java/Home/include.
I've tried JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Home" ./configure and JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home" ./configure as well but still no luck. I'd like to hear StackOverflowers' thoughts about how I can solve this.
Thanks.
Since I installed JDK1.7 from oracle, so I need to specify another JAVA_HOME.
# prepare java home
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_06.jdk/Contents/Home
cd $JAVA_HOME
sudo ln -s include Headers
# fix jni_md.h: No such file or directory problem during `make`
sudo cp include/darwin/* include/
cd -
# do real stuff
git clone http://github.com/zeromq/jzmq
cd jzmq
./autogen.sh
JAVAC=$JAVA_HOME/bin/javac ./configure
make
sudo make install
Then do a test with: (note: the first local_lat will quit by itself after the test)
java -Djava.library.path=/usr/local/lib -classpath /usr/local/share/java/zmq.jar:perf/ local_lat tcp://127.0.0.1:5555 30 100 &
java -Djava.library.path=/usr/local/lib -classpath /usr/local/share/java/zmq.jar:perf/ remote_lat tcp://127.0.0.1:5555 30 100
Should got mean latency printed.
What I did for the missing jni.h on Mac OSX Snow Leopard:
cd /Library/Java/Home
sudo ln -s /Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Headers/ ./include

Categories