[other] deepin 20.9 root用户安装jdk8
Tofloor
poster avatar
pangqiangqiang
deepin
2023-07-21 17:59
Author

使用 root 用户 vim /etc.profile 配置了jdk 后,source /etc/profile 之后 在root 用户下可以java -version ,但是重新开了新窗口后 还必须要souce 才能使用java -version . 同时对于 默认的用户 无法使用jdk. 但是 编辑 /etc/profile 不是所有用户共享吗。。。 怎么解决啊

Reply Favorite View the author
All Replies
raspbian
deepin
2023-07-21 18:06
#1

这确实有点奇怪

实在不行先在用户的.bash_profile里加一条

source /etc/profile

先将就用着

Reply View the author
master
deepin
2023-07-21 18:06
#2

为啥不用 sudo apt install?

sudo apt-cache search jdk

Reply View the author
沈拙言
deepin
2023-07-21 18:06
#3

普通用户source一下,我不知道有没有用。

但是重启一下一定可以,因为启动的时候会执行这个文件。

Reply View the author
pangqiangqiang
deepin
2023-07-21 18:09
#4
master

为啥不用 sudo apt install?

sudo apt-cache search jdk

内网 什么都没配置 ,只有现成的jdk 安装包

Reply View the author
pangqiangqiang
deepin
2023-07-21 18:10
#5
raspbian

这确实有点奇怪

实在不行先在用户的.bash_profile里加一条

source /etc/profile

先将就用着

那这样的话 是不是也只有 root可以用,我默认的用户呢

Reply View the author
pangqiangqiang
deepin
2023-07-21 18:22
#6
沈拙言

普通用户source一下,我不知道有没有用。

但是重启一下一定可以,因为启动的时候会执行这个文件。

root 用户 source后 重启了之后确实可以了 谢谢 奇怪为什么source 之后切一个窗口就不行了 重启后没问题了 直接永久使用

Reply View the author
沈拙言
deepin
2023-07-21 18:37
#7
pangqiangqiang

root 用户 source后 重启了之后确实可以了 谢谢 奇怪为什么source 之后切一个窗口就不行了 重启后没问题了 直接永久使用

首先,source只是读取并执行文件里的shell语句,比如执行新增了环境变量 export JAVA_HOME=xxx

其次,打开一个终端窗口是新开了一个进程,而export只对当前进程及当前进程的子进程有效。所以打开新终端窗口又是一个新进程,二者平级,所以新终端窗口里并没有之前export的环境变量。

而系统开机的时候会读取/etc/profile给后面的进程用。

Reply View the author
坐井观天下
deepin beta test group
2023-07-21 18:37
#8

你在/etc/profile里如何加的

Reply View the author
Ziggy
deepin
2023-07-21 18:44
#9

openjdk-8-jdk

系统仓自带

Reply View the author
pangqiangqiang
deepin
2023-07-21 19:14
#10
坐井观天下

你在/etc/profile里如何加的

目前是 重启系统后 root 和默认deepin用户可以使用 但是我配置的达梦数据库用户却调不到呢

Reply View the author
pangqiangqiang
deepin
2023-07-21 19:16
#11
沈拙言

首先,source只是读取并执行文件里的shell语句,比如执行新增了环境变量 export JAVA_HOME=xxx

其次,打开一个终端窗口是新开了一个进程,而export只对当前进程及当前进程的子进程有效。所以打开新终端窗口又是一个新进程,二者平级,所以新终端窗口里并没有之前export的环境变量。

而系统开机的时候会读取/etc/profile给后面的进程用。

好吧 可能以前用centos时没注意切换过窗口 直接的配置后 source下所有的用户就都可以使用了

Reply View the author
pangqiangqiang
deepin
2023-07-21 19:22
#12
坐井观天下

你在/etc/profile里如何加的

726713735bce029ed2c374354244b4b.jpg

Reply View the author
pangqiangqiang
deepin
2023-07-21 19:23
#13
pangqiangqiang

726713735bce029ed2c374354244b4b.jpg

这个配置 后,重启了系统 root用户 和默认 deepin用户 可以直接调用 java - version ,但是我安装达梦数据库的用户dmdba 却仍然无法调用

Reply View the author
javatango
deepin
2023-07-21 22:14
#14
pangqiangqiang

这个配置 后,重启了系统 root用户 和默认 deepin用户 可以直接调用 java - version ,但是我安装达梦数据库的用户dmdba 却仍然无法调用

改一下你的jdk安装包的路径试试,换到/opt目录下或者/usr/local目录下,然后改成

export JAVA_HOME=/opt/java... 或者export JAVA_HOME=/usr/local/java.....

Reply View the author