我正在读取jar
中的文件,但我很高兴。
我已经尝试过使用文件路径 代码:
File addonCFG;
try
{
addonCFG = new File(jarFile + "/addon.cfg");
}
catch(Exception ex)
{
throw new RuntimeException(ex);
}
我得到的例外是:
java.lang.RuntimeException: java.io.FileNotFoundException: addons\AddonTest.jar\addon.cfg (Das System kann den angegebenen Pfad nicht finden)
at net.al.Main.onEnable(Main.java:39) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:321) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:340) [spigot.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:405) [spigot.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugin(CraftServer.java:357) [spigot.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.enablePlugins(CraftServer.java:317) [spigot.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.reload(CraftServer.java:741) [spigot.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.Bukkit.reload(Bukkit.java:535) [spigot.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:25) [spigot.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) [spigot.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:641) [spigot.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchServerCommand(CraftServer.java:627) [spigot.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.DedicatedServer.aO(DedicatedServer.java:412) [spigot.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:375) [spigot.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot.jar:git-Spigot-db6de12-18fbb24]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_211]
Caused by: java.io.FileNotFoundException: addons\AddonTest.jar\addon.cfg (Das System kann den angegebenen Pfad nicht finden)
at java.io.FileInputStream.open0(Native Method) ~[?:1.8.0_211]
at java.io.FileInputStream.open(Unknown Source) ~[?:1.8.0_211]
at java.io.FileInputStream.<init>(Unknown Source) ~[?:1.8.0_211]
at java.util.Scanner.<init>(Unknown Source) ~[?:1.8.0_211]
at net.al.addon.AddonLoader.loadAddons(AddonLoader.java:62) ~[?:?]
at net.al.Main.onEnable(Main.java:36) ~[?:?]
... 16 more
编辑:jar不在类路径中。