Is there a way for a Java app to gain root permissions?

后端 未结 3 576
野的像风
野的像风 2020-12-15 07:02

When running Files.walk(Paths.get(\"/var/\")).count() as an unprivileged user, the execution might throw an exception as there are folders inside /var/

3条回答
  •  -上瘾入骨i
    2020-12-15 07:52

    There is no easy way to change permissions. Java is not good at these tasks. There are only some tricks like check permissions on start and try to change permissions via su/sudo then restart application or using Java-gnome. Please read a bit more here: Java: Ask root privileges on Ubuntu

提交回复
热议问题