java 执行 export CLASSPATH 后重置 CLASSPATH
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7252037/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Resetting CLASSPATH after doing export CLASSPATH
提问by bb2
I was trying to do a
我试图做一个
setenv CLASSPATH /somethig/foo/junit-4.9.jar
kind of thing. After doing some searching (the command setenv was not detected). I found that I had to use instead
之类的事情。进行一些搜索后(未检测到命令 setenv)。我发现我不得不改用
export CLASSPATH=/folder/junit-4.9.jar
Which didn't mark an error or anything. The problem is that it seemed to mess up other things that used to work like if I do
这没有标记错误或任何东西。问题是它似乎弄乱了其他以前可以工作的东西,就像我这样做一样
javac -Xlint FooTest.java
it says something like
它说的是
cannot find symbol variable Foo
找不到符号变量 Foo
Foo.start()
Foo comes from Foo.java and Foo.class files
Foo 来自 Foo.java 和 Foo.class 文件
And before doing the export classpath thing I was able to do this. Is there anyway to revert that?
在做导出类路径的事情之前,我能够做到这一点。有没有办法恢复它?
Where do I erase what i just added by doing the export CLASSPATH= bla bla?
我在哪里删除我刚刚通过执行 export CLASSPATH= bla bla 添加的内容?
I want to return to "the way things were" before I started adding the junit path
在开始添加 junit 路径之前,我想回到“事情本来的样子”
Thanks!
谢谢!
UPDATEif I do an echo of the value I get:
如果我对得到的值进行回显,请更新:
echo $CLASSPATH .:/folder/junit-4.9.jar:/junit-4.9.jar
Nevermind I erased the whole thing I put by setting CLASSPATH="" and now the stuff compiles.
没关系,我通过设置 CLASSPATH="" 删除了我放置的整个东西,现在这些东西可以编译了。
回答by Prabath Siriwardena
Use,
利用,
export CLASSPATH=.:$CLASSPATH:/folder/junit-4.9.jar
回答by Mu Qiao
You probably have to rebuild your classpath again as the old one has overwritten by export CLASSPATH=/folder/junit-4.9.jar
. Remember including the old classpath when you setting a new one:
您可能必须再次重建您的类路径,因为旧的类路径已被export CLASSPATH=/folder/junit-4.9.jar
. 记住在设置新类路径时包括旧类路径:
export CLASSPATH="${CLASSPATH}:/folder/junit-4.9.jar"
回答by user454322
You can do
export CLASSPATH=/folder/junit-4.9.jar:$CLASSPATH
So you will have the old value of classpath plus new value.
你可以这样做
export CLASSPATH=/folder/junit-4.9.jar:$CLASSPATH
所以你将拥有 classpath 的旧值加上新值。
if you really want to revert it, you can store it in a temp variable
export TMP_CLASSPATH=$CLASSPATH
then
export CLASSPATH=/folder/junit-4.9.jar
then
export CLASSPATH=$TMP_CLASSPATH
如果你真的想恢复它,你可以将其存储在一个临时变量
export TMP_CLASSPATH=$CLASSPATH
,然后
export CLASSPATH=/folder/junit-4.9.jar
再
export CLASSPATH=$TMP_CLASSPATH