Java classpath - Linux

后端 未结 4 1219
猫巷女王i
猫巷女王i 2020-12-31 10:58

I am trying to understand how classpath really works. After searching around the web this is where I have reached so far:

I have added

export CLASSP         


        
相关标签:
4条回答
  • 2020-12-31 11:41
     export CLASSPATH=""
    

    or better

     unset CLASSPATH
    

    will delete an existing Classpath. There are multiple locations where you can set or unset the classpath - a missing entry will not unset it.

    0 讨论(0)
  • 2020-12-31 11:44

    When you remove

    export CLASSPATH="/home/foo:/home/foo/Java_code/my_code"
    

    line and then source ... it wouldn't remove the CLASSPATH because it has already been set. It doesn't clear the variables which have already been defined.

    0 讨论(0)
  • 2020-12-31 11:46

    The /etc/environment file is not a normal shell script; it is not executed as a shell script when you boot or login into your system. So running it with source /etc/environment does not the same as when you normally boot your system.

    See: Ubuntu environment variables

    /etc/environment - This file is specifically meant for system-wide environment variable settings. It is not a script file, but rather consists of assignment expressions, one per line. Specifically, this file stores the system-wide locale and path settings.

    0 讨论(0)
  • 2020-12-31 11:51

    I think you should not put any paths that a local to your home directory in a system wide file. I would leave /etc/environment well alone, unless you provide some changes, that are necessary or beneficial to all users. Put any changes to the CLASSPATH in your .bashrc in your home directory.

      CLASSPATH=$CLASSPATH:/home/foo:/home/foo/Java_code/my_code
      export CLASSPATH
    

    This way you can source it and any newly started bash will have the settings right at once.

    0 讨论(0)
提交回复
热议问题