Code runs using IntelliJ but not in Visual Studio Code

I have a project me and my friends were working on. we initialized the project in Intellij using Gradle. when I try to run the program in vsc it gives an error. the cause of this error I believe is VSC cannot detect the resource folder where a part of the program needs to read to get input from. for some context here is the method:
public void importTOF(String filename) {
try (Scanner fileReader = new Scanner(Paths.get("src/main/resources/"+filename))) {
ArrayList<String> lines = new ArrayList<>();
while (fileReader.hasNextLine()) {
lines.add(fileReader.nextLine());
}
//the rest of the method
}
public void importTOF(String filename) {
try (Scanner fileReader = new Scanner(Paths.get("src/main/resources/"+filename))) {
ArrayList<String> lines = new ArrayList<>();
while (fileReader.hasNextLine()) {
lines.add(fileReader.nextLine());
}
//the rest of the method
}
after tinkering around with the file location I found out that the project can run if I move the file into the /project-name/ directory. is there any way I can make vsc read the file in the src/main/resources directory?
6 Replies
JavaBot
JavaBot6d ago
This post has been reserved for your question.
Hey @Oxydose! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here. 💤 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.
Oxydose
OxydoseOP6d ago
Anyone?
Kyo-chan
Kyo-chan6d ago
I mean, you could have shown the error. But I expect nobody here uses vsc
JavaBot
JavaBot5d ago
💤 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.
Oxydose
OxydoseOP5d ago
yeah, I know well the thing is I'm actually trying this for my friend, they don't use intellij cus they aren't familiar with it. when they imported the project it wont run and they have different error somehow :shrugging: should have suggested them to use intellij smh
JavaBot
JavaBot5d ago
💤 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.

Did you find this page helpful?