开发者

Where is my classpath being set?

开发者 https://www.devze.com 2022-12-23 07:10 出处:网络
Whenever I open a Bash shell, my classpath is \"someProgram\". I know that adding an export entry to \".bashrc\" changes my classpath, but I want to know where \"someProgram\" is being added to the cl

Whenever I open a Bash shell, my classpath is "someProgram". I know that adding an export entry to ".bashrc" changes my classpath, but I want to know where "someProgram" is being added to the classpath (it's not in ".bashrc").

Is there a way to track down where this is being set, or some typical spots I should be checking besides ".bashrc"?

Details:

I'm using Ubuntu 9.10.

Eclipse Version: 3.5.1 is installed.

echo $SHELL
/bin/bash

java -version
java version "1.6.0_0"
OpenJDK Runtime Environment 开发者_StackOverflow中文版(IcedTea6 1.6.1) (6b16-1.6.1-3ubuntu1)
OpenJDK Server VM (build 14.0-b16, mixed mode)

javac -version
javac 1.6.0_15

More details if requested.

Checked:

  • ~/.bashrc
  • /etc/profile
  • /etc/profile.d/*
  • ~/.bash_profile (not present)
  • ~/.bash_login (not present)
  • ~/.profile
  • /etc/bash.bashrc

Found!

/etc/environment


Ah yes, the whackamole process of finding which startup file is sourced where. I propose brute forcing it, try:

$ grep CLASSPATH .?*
$ grep -r CLASSPATH --binary-files=without-match /etc/ 2>/dev/null


in the file /etc/profile.


The answer depends on where bash reads the profile from. A well-explained answer is here. An excerpt:


When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior. ... When an interactive shell that is not a login shell is started, bash reads and executes commands from /etc/bash.bashrc and ~/.bashrc, if these files exist. This may be inhibited by using the --norc option. The --rcfile file option will force bash to read and execute commands from file instead of /etc/bash.bashrc and ~/.bashrc.



Recheck all of those files to see if they source any other files using the "." builtin command.

0

精彩评论

暂无评论...
验证码 换一张
取 消