Making sure JAVA_HOME is correctly set

前端 未结 6 572
北荒
北荒 2020-12-12 22:49

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:

I

6条回答
  •  庸人自扰
    2020-12-12 23:21

    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
    

提交回复
热议问题