Blog coding and discussion of coding about JavaScript, PHP, CGI, general web building etc.

Tuesday, January 5, 2016

Making sure JAVA_HOME is correctly set

Making sure JAVA_HOME is correctly set


Pretty new to Java and also to Mac ... I want to make sure JAVA_HOME is set so in other programs I can use its path. So I did some Googling and here is what I got:

If I enter /usr/libexec/java_home in terminal I get this: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home but if I enter echo $JAVA_HOME in terminal, I don't get anything back.

Can you please tell me what is going on in here?

Thanks.

Answer by Steve McGuire for Making sure JAVA_HOME is correctly set


JAVA_HOME isn't set by default on OSX. You can resolve this by opening terminal and executing the following:

echo "export JAVA_HOME=`/usr/libexec/java_home`" >> ~/.profile      . ~/.profile  

This will cause JAVA_HOME to be set on startup (rather than just the current session), and immediately add it.

Answer by Hashken for Making sure JAVA_HOME is correctly set


Edit your /etc/launchd.conf in your text editor. If it does not exist create it.

Then append the following line to the file: setenv JAVA_HOME /path/to/java/installation

OR

just type the following command in terminal
sudo echo setenv JAVA_HOME /path/to/java/installation >> /etc/launchd.conf Then just enter your password when it prompts.

Now reboot your computer and the changes should have taken place.

Note :
I am giving you advice based on my experience in Linux. But, these should work on MAC also.

Source

Answer by Atharva for Making sure JAVA_HOME is correctly set


The empty value of the echo command would mean that the value has not been set correctly as you are expecting. You can try creating/editing ~/.profile by adding the lines something like:

vi ~/.profile  export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home    

if you are not yet comfortable with vi editor, you may also create that file in your home directory using TextEdit program in Mac. and execute

source ~/.profile  

That will load set the JAVA_HOME property. Next you can try out executing echo $JAVA_HOME to check whether it has been set correctly as you expect.

You may also need to set PATH environment variable as something like:

export PATH=PATH:$JAVA_HOME/bin  

Answer by Martin Cleaver for Making sure JAVA_HOME is correctly set


This is not resilient to new installs of the JDK. According to Apple: - you should not set it globally - you should use libexec

http://lists.apple.com/archives/java-dev/2011/May/msg00040.html

You might think that:

$ cat /etc/launchd.conf setenv JAVA_HOME /usr/libexec/java_home

would work - but no, it sets it literally.

But, as I say, according to that Apple Engineer, you are not supposed to set it globally anyway. :(

Answer by WebEpic for Making sure JAVA_HOME is correctly set


Checking JAVA_HOME path

Try running source .bash_profile prior to echo $JAVA_HOME. This should correct the problem if you've set JAVA_HOME correctly.

  • Explanation: source loads and runs your bash_profile.

If you haven't set JAVA_HOME correctly, following the instructions below should clear things up.

  • vim .bash_profile ? opens your bash_profile in Vim.
    • I've included a list of VIM commands you'll likely need to edit your .bash_profile below.

  • export JAVA_HOME=$(/usr/libexec/java_home) ? creates an ENV_VAR (Environment Variable) and sets/stores the home path of the JDK to (/usr/libexec/java_home).
  • source .bash_profile ? loads and runs your updated bash_profile
  • echo $JAVA_HOME ? returns the value stored in the ENV_VAR JAVA_HOME, which is the home path of your JDK installation.

VIM Commands:

Vim is an editor to create or edit a text file. There are two modes in vim.

  • Command Mode: user can move around the file, delete text, etc.

  • Insert Mode: user can insert text.

Changing between modes:

Command mode to Insert mode

  • type the appropriate letter for the action you want (a, A, i, I, o, O) -- details for letters below.

Insert mode to Command mode

  • press Esc (escape key)

Text Entry Commands (Used to start text entry)

  • a -- Append text following current cursor position

  • A -- Append text to the end of current line

  • i -- Insert text before the current cursor position

  • I -- Insert text at the beginning of the cursor line

  • o -- Open up a new line following the current line and add text there

  • O -- Open up a new line in front of the current line and add text there

Cursor Movement Commands (only used in the commands mode.)

  • h -- Moves the cursor one character to the left

  • l -- Moves the cursor one character to the right

  • k -- Moves the cursor up one line

  • j -- Moves the cursor down one line

  • nG or :n -- Cursor goes to the specified (n) line

  • (ex. 10G goes to line 10)

  • $ -- Move cursor to the end of current line

  • 0 -- (zero) Move cursor to the beginning of current line

  • w -- Forward one word

  • b -- Backward one word

Exit Commands

  • :wq -- Write file to disk and quit the editor

  • :q! -- Quit (no warning)

  • :q -- Quit (a warning is printed if a modified file has not been saved)

  • ZZ -- Save workspace and quit the editor (same as :wq)

VIM Editor Commands -- full list


Fatal error: Call to a member function getElementsByTagName() on a non-object in D:\XAMPP INSTALLASTION\xampp\htdocs\endunpratama9i\www-stackoverflow-info-proses.php on line 72

0 comments:

Post a Comment

Popular Posts

Powered by Blogger.