系统找不到jar中指定的路径 [英] System cannot find path specified in a jar

查看:102
本文介绍了系统找不到jar中指定的路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个jar文件,但我不断从资源中获取系统无法找到指定的路径。我只能从可运行的jar文件启动它而不是从IDE启动它时出错是不能在jar文件上运行的代码行。



I'm trying to make a jar file but i keep getting "The system cannot find the path specified" from a resource.I only get the error when I launch it from a runnable jar file but not from an IDE.here are the lines of code that won't run on a a jar file.

File file = new File("src/scores/scores.txt");
PrintWriter b = new PrintWriter(file);

推荐答案

试试这个



Try this

public InputStream getResourceAsStream(String name)





来读取jar内的资源。



更多信息点击此处



例如点击此处


这篇关于系统找不到jar中指定的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆