I want to run solR in mac OSX 10.9.1. So I installed JRE latest version. Then, I downloaded solR and expanded the folder. But when I try to run this jar file in example folder, I get this msg "no java runtime present", mentioned below.
Do I need to add JAVA_HOME env variable like we do in windows? If so, please tell me how.
Ananyas-MacBook-Pro:~ ananya$ /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java -version
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build
1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
Ananyas-MacBook-Pro:~ ananya$ cd /Users/ananya/Desktop/VT\ study/solr-4.6.1/example
Ananyas-MacBook-Pro:example ananya$ java -jar start.jar
No Java runtime present, requesting install.
Ananyas-MacBook-Pro:example ananya$
Thanks.
"Do I need to add JAVA_HOME env variable like we do in windows?"
Test to see if/where Java is on your path in a terminal:
echo $JAVA_HOME
If the path to Java is wrong or missing you can add and Environmental Variable to ~/.bash_profile like so
JAVA_HOME=/usr/bin/java #or whatever your path is
export PATH=$PATH:$JAVA_HOME/bin/
You can open ~/.bash_profile in a terminal with nano
nano ~/.bash_profile.
Nano hint: writeout means save.
You'll need to reopen your terminal to load the new path. Or, reload it with the source command.
source ~/.bash_profile
Alternatively, if you like saving keystrokes you can type
. ~/.bash_profile
Related
I am working on Amazon ec2 for the first time and verified java version by using the command java -version and got the below results:
openjdk version "1.8.0_201"
OpenJDK Runtime Environment (build 1.8.0_201-b09)
OpenJDK 64-Bit Server VM (build 25.201-b09, mixed mode)
And also run the command javac -version, but no results. From this, I have understood the javac is not set and none of the java related applications are running. Can anyone please tell me how to resolve this problem?
javac should be in the bin directory of the java installation dir and java in the jre/bin directory. You could run dirname $(readlink -e $(which java)) to find out the absolute path to the jre/bin dir and then modify it to the bin dir. The result is added to your PATH variable in your ~/.profile.
Add this line to your ~/.profile (or ~/.bash_profile or ~/.bashrc, whichever is read on startup)
export PATH=$PATH:$(readlink -e $(dirname $(readlink -e $(which java)))/../../bin)
Then logout and login again and test if javac -version works as expected.
AFTER SETTING YOUR SYSTEM VARIABLE TO JAVA_HOME YOU NEED TO DO THIS FOR IT WORK ON YOUR COMMAND PROMPT:
After setting the JAVA_HOME system variable you need to also set the path so you can use javac from the command prompt:
After setting the JAVA_HOME system variable:
Inside System Variables find "Path" and click "Edit"
At the end of the Path add this line: ";%JAVA_HOME%\bin" (without the double quotes)
Now click "Ok" and exit out of your command prompt window (If it's still open)
now try "javac -version" and it should work
You can also check your java version, JRE build version, and Java Server VM build by typing "java -version"
I'm using PowerShell on Windows 2012 server, and I deleted all the java commands from System32, reinstalled jdk, set JAVA_HOME and Path to point at the new installation. And I still get the following error:
java : The term 'java' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ java
+ ~~~~
+ CategoryInfo : ObjectNotFound: (java:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
I deleted all the java commands from System32
This is why Windows can't find java.exe. The default JRE installation puts Java into your System32 directory, which is where CMD and Powershell usually find it.
You can fix this for your system by running the following from an admin shell. This creates a copy of java.exe in your Windows directory. (You can also probably get away with a soft link)
fsutil hardlink create (join-path $env:SystemRoot 'java.exe') (join-path $env:JAVA_HOME 'bin\java.exe')
If you don't want to modify your Windows directory (or can't), you can always set an alias to use in your Powershell session.
Set-Alias -Name java -Value (Join-Path $env:JAVA_HOME 'bin\java.exe')
Run that line in your current session and running java from the command line should work correctly. Add it to your $PROFILE if you want it to work from all future Powershell sessions.
PATH needs to point at the bin/ directory within the JDK/JRE installation
JAVA_HOME needs to point to the top level directory of the JDK/JRE
I suspect you're setting PATH to be the JDK/JRE folder which doesn't contain the java executable, as it's in the bin/ subdirectory...
1) My default JAVA_HOME is:
echo %JAVA_HOME%
D:\Program Files\Java\jdk1.7.0_25
<= The installer automagically configures this when you install a JRE
2) My default %PATH% does not include any Java
3) I'm able to run (but not compile) Java from a Windows command prompt:
java -version
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
4) I'm also able to do exactly the same from inside Powershell (or from a .ps1 Powershell script):
PS D:\temp> java -version
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
When I open eclipse in Ubuntu it is showing the following error:
A Java Runtime Environment (JRE) or Java Development Kit (JDK)
must be available in order to run Eclipse. No Java virtual machine
was found after searching the following locations:
/opt/eclipse/jre/bin/java
java in your current PATH
These are the Environment variables I set in .bashrc file:
JAVA_HOME=/opt/jdk1.7.0
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
JRE_HOME=/opt/jdk1.7.0
PATH=$PATH:$HOME/bin:$JRE_HOME/bin
export JAVA_HOME
export JRE_HOME
export PATH
I have also checked in terminal:
asr#asr-desktop:~$ java -version
java version "1.7.0"
Java(TM) SE Runtime Environment (build 1.7.0-b147)
Java HotSpot(TM) Server VM (build 21.0-b17, mixed mode)
asr#asr-desktop:~$ which java
/opt/jdk1.7.0/bin/java
asr#asr-desktop:~$ echo $JAVA_HOME
/opt/jdk1.7.0
asr#asr-desktop:~$ echo $PATH
/opt/softwares/apache-ant-1.7.1/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/vidyayugpc/bin:/opt/jdk1.7.0/bin:/home/vidyayugpc/bin:/opt/jdk1.7.0/bin
The eclipse is opening via command prompt only, I have tried to specify JVM location in eclipse.ini file by adding the below line
-vm
/opt/jdk1.7.0/bin/java
But its not running again showing the same error jvm is not found.Can any one help me here?
This work for me edit the eclipse.ini using any text editor and change your -vm path to real path of your JDK
-vm /opt/jdk1.6.0/bin/
You should set the Environment variables in /etc/profile or /etc/profile.d/ and reboot.
I don't know exactly, your path seems fine
If you set up the -vm parameter you have to point to the bin folder, please try this:
-vm /opt/jdk1.7.0/bin/
i am new to ubuntu .initially i installed java in Ubuntu.
But i haven't set any envionment variables
After that installed maven build tool to build java package.when i compiled with build tool it shows some error says generic supports after 1.3 packages.
so i realize it JDK runs with 1.3. so i need set java environment variables for latest version
so in my Terminal java -version shows
beeshma#ubuntu:~$ java -version
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)
and i set java environment variables in through below steps
[https://askubuntu.com/questions/277806/how-to-set-java-home][1]
sudo gedit ~/.bashrc
Now go to end of file and add the following lines:
export JAVA_HOME=/path/to/jdk/folder
#usually /usr/java/jdk or /usr/lib/java/jdk
export PATH=$PATH:$JAVA_HOME/bin
Now in terminal type:
sudo source ~/.bashrc
This will make it appear on every terminal if open.
Now you can cross check it by typing following line in terminal
$echo $PATH
/usr/java/jdk1.7.0_45//bin:/home/beeshma/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/java/jdk1.7.0_45//bin
What my question when i execute mvn --help
Fallowing error is coming
beeshma#ubuntu:~$ mvn -version
Error: JAVA_HOME is not defined correctly.
**We cannot execute /usr/java/jdk1.7.0_45//bin/java**
Try changing your export to:
export JAVA_HOME=$(/usr/java/jdk1.7.0_45)
Two things:
Try if /usr/java/jdk1.7.0_45//bin/java is indeed present.
See if the beeshma user has the permissions to 'execute' java.
Bonus: remove the trailing / in your JAVA_HOME value.
You can install the JDK with the following command:
$sudo apt install default-jdk
The above command also sets the java environment variable automatically
I am having a problem opening uiautomatorviewer on mac.
This is what I get on the terminal when I issue the command uiautomatorviewer:
???#???-MacBook-Pro-2 libexec % uiautomatorviewer
SWT folder '/usr/local/Caskroom/android-sdk/4333796/tools/lib/
ERROR: JAVA_HOME is set to an invalid directory: /usr/libexec/java_home
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.' does not exist.
Please export ANDROID_SWT to point to the folder containing swt.jar for your platform.
Any suggestion?
You have not defined JAVA_HOME in your system path. To do this:
Open Terminal
Confirm you have JDK by typing “which java”. It should show something like /usr/bin/java.
Check you have the needed version of Java, by typing “java -version”.
JAVA_HOME is essentially the full path of the directory that contains a sub-directory named bin which in turn contains the java.
For Mac OSX – it is: /Library/Java/Home
Set JAVA_HOME using this command in Terminal: export JAVA_HOME=/Library/Java/Home
echo $JAVA_HOME on Terminal to confirm the path
You should now be able to run your application
Note that this sets JAVA_HOME only for this session. If you want it to persist, you will have to add the command to your ~/.profile file. Below are instructions on how to accomplish this instead:
Open up Terminal.app (Applications >> Utilities >> Terminal)
Type: emacs .profile
add this to the end of the .profile file:
JAVA_HOME=/Library/Java/Home
export JAVA_HOME;
Save and exit emacs (ctrl-x, ctrl-s; ctrl-x, ctrl-c)
Open a new Terminal window (cmd-n) and type: $JAVA_HOME/bin/java -version
If you see something like:
java version “1.8.0_16″
Java(TM) 2 Runtime Environment, Standard Edition (build 1.8.0_16-b06-284)
Java HotSpot(TM) Client VM (build 1.8.0_16-133, mixed mode, sharing)
Then you’ve successfully set your JAVA_HOME environment variable to the binary stored in /Library/Java/Home/bin/java
Source: SajeConsultants