According to ORACLE's doc Quick Start for Platform Developers I used Jrecreate and got JRE .
I copied JRE to my Arm Linux, cd ./bin and inputted java -version.
But terminal displayed:-sh:java:not found
Do I miss any Share Library?
If you want an executable from your current directory to be callable by name you need . to be included in your $PATH, which isn't the case by default due to security concerns. Otherwise you have to provide an absolute or relative path to the executable such as ./java.
Another solution, which is the most common for java and other language development tools / runtime environments, would be to include the absolute path to your Java install's bin directory in the $PATH so that you can run java from anywhere. This is often done by first setting a $JAVA_HOME environment variable, then including $JAVA_HOME/bin in your path :
export JAVA_HOME="/usr/bin/java/" # or whatever your install path is
export PATH="$JAVA_HOME/bin:$PATH"
Either enter the location where your java executable actually is or add the java binary to your PATH environment variable.
If you read Oracles documentation, you need to do this after having run Jrecreate. (Please adapt destDir)
Recursively copy destDir from the host to the device directory where you want the JRE installed. For example:
$ scp -r /tmp/SmallJRE/* root#target:/opt/local/ejdk<version>/
If necessary, update the device's PATH environment variable to include the bin/ directory of the JRE. For instance:
$ PATH=$PATH:/opt/local/ejdk<version>/bin/
$ export PATH
Need some lib.and i used uclibc that don't support JRE.
Related
This question already has answers here:
javac is not recognized as an internal or external command in windows 7
(3 answers)
Closed 2 years ago.
My current system config is -
Netbeans 12.0
JDK 14.0.2
Windows 10 (64bit)
I have added the environmental variable in PATH manually i.e. C:\Program Files\Java\jdk-14.0.2\bin.
I tried adding using cmd as well. As well as adding the JAVA_HOME as a new variable with value as C:\Program Files\Java\jdk-14.0.2 .
I have used the set command to do this process i.e. set path = "%path%;"C:\Program Files\Java\jdk-14.0.2\bin". Also, I have used the same command without the set keyword.
Since javah command was deprecated for versions of jdk>8, I have tried to use javac -h command as well.
I have also tried to install JDK v. 8.0.2 instead of the current one.
Although there's no javah.exe file in the bin folder, there is however javac.exe file.
I have uninstalled and reinstalled JDK and Netbeans quite a few times.
I am currently working on JNI with Netbeans IDE and C/C++ plugin. (I have successfully installed Cygwin and necessary extension for the file to build. Although I don't know how they affect this problem, still I thought I should add this).
The command I wish to use with 'javah' is the one used for creating a C header from a Java class i.e. 'javah -o JNIDemoJava.h -classpath JNIDemoJava/build/classes jnidemojava.Main'.
But due to this error, I have been stuck for a few days. Please do assist.
Following way you can set Path variable temporary(it can only be used in the same command line):
You should do it this way:(notice =)
set PATH=C:\Program Files\Java\jdk-14.0.2\bin
And if you set JAVA_HOME variable correctly you can do it this way:
set PATH="%JAVA_HOME%\bin"
For setting this permanently read this post :
https://javatutorial.net/set-java-home-windows-10
We should know the reason for this
Our OS comes with a predefined (built-in)set of tools and utilities. When we try to execute the command e.g. cls in the Windows command line then it is already present in system path variable and os will refer the corresponding binary of cls to execute the command.
However, when we install any third party tool/software then path variable is not updated accordingly.
When we install different versions of java on your system then installations go to different directories. E.g. JDK installation directory for Windows will be
C:\Program Files\Java\jdk1.8.0_161
Similarly, JRE installation directory for Windows will be JDK installation directory for Windows will be
C:\Program Files\Java\jre1.8.0_161
We need to update the path variable of OS to point to the appropriate directory. If we set the path of JDK then it will execute a binary from JDK bin directory.
Solution
we need to update JDK or JRE version specific directory location into PATH Environment variable.
In this case use
set path=C:\Program Files\Java\jdk-14.0.2\bin to set JAVA_PATH
I want to upgrade my Linux JDK from Oracle to Azul-Zulu.can someone helps me to do this.
What to do after downloading the tar.gz Zulu package?
I see that after extracting the downloaded package we need to put it in the path where we need to access java. Is that correct or what we can do more like setting environment variables etc.
the answer to your question depends on what you actually want to start with the JDK. Sometimes is is sufficient to change the path to java binary in a start script, e.g. Eclipse or Tomcat, sometimes you also need to setup the variable JAVA_HOME.
To setup the java for yourself only:
Check your shell by running echo $SHELL
-> /bin/bash
-> /bin/zsh
-> /bin/tcsh
or something like that Locate your shell's config file:
bash: ~/.bashrc
zsh: ~/.zshrc
tcsh: ~/.cshrc or ~/.tcshrc
and optionally most of the shells: ~/.profile or ~/.login check those file(s) if you already have variable declarations for: JAVA_HOME JRE_HOME (and rarely seen) SDK_HOME JDK_HOME
check whether any of those files contain a setup for the variable PATH (probably has)
If you found any of the *_HOME variables from above you can change them to reflect your new java home directory: e.g. zulu11.37.17-ca-jdk11.0.6-linux_x64 located under /opt/zulu11.37.17-ca-jdk11.0.6-linux_x64 would mean to set the variables as follows: zsh and bash:
export JAVA_HOME=/opt/zulu11.37.17-ca-jdk11.0.6-linux_x64
export JRE_HOME=/opt/zulu11.37.17-ca-jdk11.0.6-linux_x64
tcsh
setenv JAVA_HOME /opt/zulu11.37.17-ca-jdk11.0.6-linux_x64
setenv JRE_HOME /opt/zulu11.37.17-ca-jdk11.0.6-linux_x64
SDK_HOME and JDK_HOME may point to the above locations as well but are normally unused.
If you located your PATH somewhere it may read something like this: zsh and bash:
export PATH=~/bin:$PATH
tcsh:
setenv PATH ~/bin:$PATH
In order for your new java to appear "before" the "other" java you need to update (or create if missing) this to e.g.: zsh and bash:
export PATH=~/bin:/opt/zulu11.37.17-ca-jdk11.0.6-linux_x64/bin:$PATH
tcsh:
setenv PATH ~/bin:/opt/zulu11.37.17-ca-jdk11.0.6-linux_x64/bin:$PATH
After completely logging out and in again your JAVA_HOME and PATH can be controlled in a shell like this:
echo $JAVA_HOME -> should point to *your* java folder
echo $PATH -> should contain *your* java folder's bin directroy
which java -> should list the new java binary instead of /bin/java or /usr/bin/java
BTW: the variables JAVA_HOME, JRE_HOME and PATH may also be set in a startscript, e.g. catalina.sh for tomcat or the eclipse.ini for eclipse if you do not want to modify your environment.
If you download the RPM/DEB instead of the tar.gz and install the package you (may) not need configure anything since the packages might re-configure your system for you
Cheers, Holger
I'm getting the following error when I try to run the 'jar' command in the command line on windows :
'jar' is not recognized as an internal or external command
The general solution seems to be that I need to add the jdk bin folder to the PATH in environment variables. I have already done this, I added the following to the path variable :
...; C:\Program Files\Java\jdk1.8.0_40\bin\;
Though I'm not sure if having the jdk reside in 'program files' instead of 'program files x86' affects this. I'm on 64 bit windows with 64 bit java.
Thanks
The path should only contain directories where the OS will look for executables. Strip the trailing "\jar.exe" to set your path as:
(old path variables here);C:\Program Files (x86)\Java\jdk1.7\bin
Thanks To : #stevevls
Try using this command:
java -version
If it doesn't work that means you failed to properly add path to jdk.
If it does work, try using:
java -jar
The jar command in command line is used in order to create a JAR file. For example:
jar cf jar-file input-file(s)
See more at: Oracle docs
If you want to run the existed JAR file you should use the java -jar command mentioned by #Aleksandr.
But in your case it looks like you don't have an access to the added directory in your path with JKD binaries so at the beginning try to execute mentioned java --version to check whether you have java in you classpath at all.
Please remember that on Windows you have to restart the console when you change the windows default path. You do not see the changes on the current console.
The x64 version of Java is installed on Program Files. The x86 version is installed on Program Files x86 by default.
Five steps to solve this problem:
check whether in your bin folder jar.exe is availbale or not
check for your environmental setting
download jar file from here http://originaldll.com/file/jar.exe/29248.html and keep in bin folder
now check for jar it will 100% work
keep any jar in your desktop and go to desktop path on cmd prompt and run the command jar xf filename.jar
Now see if it is working
I have Ubuntu 10.10 with java already installed. I am able to execute java command from any folder. I supposed that could be because I had java Classpath setted. But neither JAVA_HOME nor CLASSPATH are setted.
If I look at /etc/environment content I can see that PATH is setted to /usr/bin/ (among others). As 'which java' returns /usr/bin/java, is that the reason why I can execute java from anywhere? If not, why is it?
You can execute java because the command is on your path.
echo $PATH
will show you which directories are searched, in which order to find a particular program. Since /usr/bin is on your path, when you type java it will eventually look at /usr/bin/java. Note that in many systems this is a symbolic link (a file that points to another file) so /usr/bin/java often points to /etc/alternatives/java (which is also a symbolic link that points to the real executable).
Where the environmental variable JAVA_HOME comes into play is in tools and programs that check for JAVA_HOME and act on it instead of relying on the path. In most modern Linux systems, the work done by the alternatives subsystem replaces the earlier (more problematic) JAVA_HOME technique. That said, you might want to set JAVA_HOME anyway, should you encounter a tool that demands it.
One reason why JAVA_HOME is not as popular as it could be is that to access JAVA_HOME you need to run a shell, and not everyone wants to wrap every single Java item in a shell command.
Yes, if java binary (or a link to it) is on a folder that is listed on the path then you can execute java without specifying the path to it (for example /usr/local/java/latest/bin/java -jar x.jar)
JAVA_HOME and CLASSPATH have nothing to do with system path.
JAVA_HOME allow other software (or scripts) to know where to look for java installation.
CLASSPATH tells java where to look for classes (.class files resulting of compiling .java files).
I have made a jar file which i tested in windows and it works fine. now i want to test it for red hat enterprise linux 5. but i dont know how to run jar files in rhel5.
i've tried java -jar My.jar but it says bash: java: command not found. i've set JAVA_HOME variable as export JAVA_HOME=/root/jdk1.6.0_21 but still not working.
can anybody tell me how to run jar file in rhel5?
You need to set PATH variable , something like
export PATH=$PATH:/usr/java/jdk1.5.0_07/bin
replace /usr/java/jdk1.5.0_07/bin with path to your jdk's bin directory.
The problem is your terminal tries to find java command from the PATH , but it couldn't find it.
Update:
You need to setup global config in /etc/profile OR /etc/bash.bashrc file for all users:
# vi /etc/profile
Next setup PATH / JAVA_PATH variables as follows:
export PATH=$PATH:/usr/java/jdk1.5.0_07/bin
export PATH=$PATH:/usr/java/jdk1.5.0_07/bin
Top tip but slightly off topic.
1) Install your JDK in /usr/local/jdkX.X.X_XX/
2) Create a symbolic link /usr/local/java -> your chosen JDK installation
When you install new versions of java or if you want to revert to an older version, just change the symbolic link.