Cants seem to get java to recognize a text file.
I cant seem to get java to recognize a text file
44 Replies
⌛
This post has been reserved for your question.
Hey @stapps! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
What do you mean with recognize a text file? Why should it?
So I can print out how many words are in the text filw
What happens when running your program?
It's says it doesn't see it, I'll take a screenshot after I get back
It seems you are running the program in C:\Users\Admin so it expects the file to be there
the file is in the same folder as the program
yeah but that's not where you run the program
?
is where its ran and where the program is different?
yes
oh
For example assume you have a directory
a
with a directory b
in it and your program is located in b
If you are in directory a
and run ./a/b
(so you run the program from directory a
), it still runs in directory a
so if it tries to access test.txt
, it looks for it in a
lemmie try putting them both in a different folder to see if anything changes
so would i have to put the text file in a different directory or make the directory different?
Here, I think you are running the program in C:\Users\Admin so the file would need to be there
yeah, you can also run the program from another directory
like this?
the test.txt would need to be in C:\Users\Admin
or just run the program in the directory where the test.txt is
is this not C:\User\admin?
I don't know
you just wrote C:\Users\fnum in the top bar
i did not, i moved it to the directory, it still wont work :'D
actually, the error is different now
So how are you running the application and where is the test.txt file?
both the file and program files are in the same folder
and how do you run that?
i press the run button
It doesn't matter whether they are in the same folder if you run it from another folder
how would i run it from another folder?
then VSC is configured to rujn it in some folder
Is there a launch.json?
idk
Can you configure how you are running the Java application in VSC?
idk VSC much
i think so, im moving the entire vcs to the desktop to see if that works
When i run a Java program in VSC/Theia, I have a settings icon
when I click it, it opens a launch.json
this has an entry like this
and I can add a
cwd
entry which specifies where the program is runis this the same?
if you specify the full path there, you need to specify the path to the file, not the path to the directory
so
"C:\\Users\\fnum\\test.txt"
or similaroh
different error message this time
IT WORKS
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
.Close
.close