0

When I use the java/javac command on cmd as in

javac Theory/HelloWorld.java java Theory.HelloWorld

it works just fine, yet when I do that on the VSCode terminal it doesn't work at all and says "Error: Could not find or load main class Theory.HelloWorld. Caused by: java.lang.ClassNotFoundException: Theory.HelloWorld"

Running the code with the Run Java button works just fine, it's just when I want to add arguments Any ideas?

PS: Using the java -cp . Theory/HelloWorld works fine, it's just that it becomes a mess when I try to use that command when the main class uses different classes

I've tried set CLASSPATH=. Clean Java Language Server Workspace Used different terminals Configured Classpath in VSCode with the "." path

BODDAH
  • 1
  • 1
    *it's just that it becomes a mess when I try to use that command when the main class uses different classes* How so? Please give an example. – g00se Aug 12 '23 at 19:05
  • "it becomes a mess when I try to use that command when the main class uses different classes", why? You don't need to put every class on the classpath, just the root directory or jar(s) or some such. – Kayaman Aug 12 '23 at 19:06
  • When the main class is using different classes in the same package, if I want to run the command javac [location].java it says that it cannot find symbol [Class name] – BODDAH Aug 12 '23 at 19:46
  • Just try `javac -cp . Theory/*.java` – g00se Aug 12 '23 at 19:56
  • is the cwd the same in both cases you are comparing? – starball Aug 13 '23 at 21:51
  • Should be related to your working directory. Can you show your workspace and project structure? – JialeDu Aug 14 '23 at 08:35
  • Any updates here? – JialeDu Aug 31 '23 at 01:23

0 Answers0