-1

I have VSCode Version: 1.52.1, macOS Big Sur, Version 11.1. I have the following directory structure:

Home > 
      cplus_cplus_projects
      java_projects
      python_projects

When i cd into Home, i usually do code python_projects to work on python related work. Or, code cplus_cplus_projects to work on c++ code. Now, i want to do code java_projects to work on a simple QuickStart.java file.

When i do code java_projects, my VSCode opens up with a .vscode which contains a settings.json.
Inside java_projects, i created a new file called QuickStart.java So, heres the structure:

java_projects >
               .vscode
               QuickStart.java

When I installed code-runner yesterday, it compiled with no issues. I've removed and did a completely new install of VSCode by following another thread here to remove all the files. I did this:

rm -fr ~/Library/Preferences/com.microsoft.VSCode.helper.plist 
rm -fr ~/Library/Preferences/com.microsoft.VSCode.plist 
rm -fr ~/Library/Caches/com.microsoft.VSCode
rm -fr ~/Library/Caches/com.microsoft.VSCode.ShipIt/
rm -fr ~/Library/Application\ Support/Code/
rm -fr ~/Library/Saved\ Application\ State/com.microsoft.VSCode.savedState/
rm -fr ~/.vscode/

After removing this, and reinstalling VSCode, it compiled and executed fine. Heres the contents of QuickStart.java

public class QuickStart{
public static void main(String[] args)
{
    System.out.println("hello there");
}
}

My VScode runs when i click the run-debug option. Just not with code-runner. However, it worked yesterday with code-runner. Error Message I'm getting:

[Running] cd "/Users/raj/Documents/QuantResearch/Home/java_projects/" && javac 
QuickStart.java && java QuickStart
error: file not found: QuickStart.java
Usage: javac <options> <source files>
use --help for a list of possible options

[Done] exited with code=2 in 0.911 seconds

enter image description here

turtle_in_mind
  • 986
  • 1
  • 18
  • 36

1 Answers1

0

The solution i found, that i hope helps someone in the event they face the same issue, was to go to my settings.json file and add this:

"code-runner.executorMap": {
    "java": "cd $dir && java $fileName",
}

For some reason, when i cd in to my directory and typed java QuickStart.java, it compiles in my terminal. But javac QuickStart.java gives the error "QuickStart.java" not found

turtle_in_mind
  • 986
  • 1
  • 18
  • 36