简体   繁体   English

让 Java 可以访问 ubuntu 服务器中的目录/文件

[英]let Java have access to a directory/file in ubuntu server

i'm creating a Minecraft server but when i execute "java -Xmx3G -jar paper-1.19-81.jar nogui" i get the error: "java.nio.file.AccessDeniedException: ./Lobby/session.lock".我正在创建一个 Minecraft 服务器,但是当我执行“java -Xmx3G -jar paper-1.19-81.jar nogui”时出现错误:“java.nio.file.AccessDeniedException: ./Lobby/session.lock”。

it work fine with sudo on the root user but i don't want to use it because of some security issues.在 root 用户上使用 sudo 可以正常工作,但由于一些安全问题,我不想使用它。 Do anyone know how to let java have access to this file?有谁知道如何让 java 可以访问这个文件?

Starting org.bukkit.craftbukkit.Main
System Info: Java 17 (OpenJDK 64-Bit Server VM 17.0.4+8-Ubuntu-122.04) Host: Linux 5.15.0-43-generic (amd64)
Loading libraries, please wait...
[11:49:32 INFO]: Building unoptimized datafixer
[11:49:34 INFO]: Environment: authHost='https://authserver.mojang.com', accountsHost='https://api.mojang.com', sessionHost='https://sessionserver.mojang.com', servicesHost='https://api.minecraftservices.com', name='PROD'
[11:49:34 ERROR]: Failed to start the minecraft server
java.nio.file.AccessDeniedException: ./Lobby/session.lock
        at sun.nio.fs.UnixException.translateToIOException(UnixException.java:90) ~[?:?]
        at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106) ~[?:?]
        at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111) ~[?:?]
        at sun.nio.fs.UnixFileSystemProvider.newFileChannel(UnixFileSystemProvider.java:181) ~[?:?]
        at java.nio.channels.FileChannel.open(FileChannel.java:298) ~[?:?]
        at java.nio.channels.FileChannel.open(FileChannel.java:357) ~[?:?]
        at net.minecraft.util.DirectoryLock.create(DirectoryLock.java:26) ~[?:?]
        at net.minecraft.world.level.storage.LevelStorageSource$LevelStorageAccess.<init>(LevelStorageSource.java:398) ~[?:?]
        at net.minecraft.world.level.storage.LevelStorageSource.createAccess(LevelStorageSource.java:323) ~[?:?]
        at net.minecraft.server.Main.main(Main.java:156) ~[paper-1.19.jar:git-Paper-81]
        at org.bukkit.craftbukkit.Main.main(Main.java:294) ~[paper-1.19.jar:git-Paper-81]
        at io.papermc.paperclip.Paperclip.lambda$main$0(Paperclip.java:42) ~[app:?]
        at java.lang.Thread.run(Thread.java:833) ~[?:?]
mcserver@minersworld:~/minersworldserver$```

This most likely means that your server crashed and your world may be corrupted.这很可能意味着您的服务器崩溃并且您的世界可能已损坏。 Make a backup of the world directory, delete the lock file, and load up the server.备份世界目录,删除锁文件,加载服务器。 If the world has some corrupted or reset chunks, you may have to load a backup of it you made previously that you have stored elsewhere.如果世界有一些损坏或重置的块,您可能必须加载您之前保存在其他地方的备份。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM