Click here to Skip to main content
15,938,218 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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);
Posted
Updated 20-Jun-13 20:39pm
v2
Comments
Richard C Bishop 20-Jun-13 16:32pm    
You probably need the fully qualified path to the file.
coder_maniac512 20-Jun-13 16:36pm    
how would i do that? Sorry im quite new to java
Richard C Bishop 20-Jun-13 16:56pm    
That just means to make sure your file path goes all the way to the root. Say C: or whatever drive you are using.
H.Brydon 21-Jun-13 19:13pm    
Your code looks like it is for linux/unix. You probably want "/src/scores/scores.txt" instead of "src/scores/scores.txt" as file spec.

1 solution

Try this

Java
public InputStream getResourceAsStream(String name)


to read the resource inside the jar.

For more Info Click here.

For example click here.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900