0

I'm writing a code to run the original coded program from my professor through the class files. So basically I downloaded my coded program of my professor to start coding a class file in the visual studio code. But when I run, it could not find my class file which means that I haven't compiled it, then I have searched up some ways to compile the file which has the javac or some like that and it turned out: "'javac' is not recognized as an internal or external command operable program or batch file. The system cannot find the path specified." So how can I easily compile the class file and set the classpath?

  • Take a look at [this](https://stackoverflow.com/questions/7709041/javac-is-not-recognized-as-an-internal-or-external-command-operable-program-or). – MikaelF Mar 12 '20 at 00:11
  • See https://code.visualstudio.com/docs/languages/java – admlz635 Mar 12 '20 at 00:12

2 Answers2

0

Visual Studio Code is just a code editor. VS Code can't actually compile your code: Only help you write it. Various extentions to VS Code can automate the process of running the compiler, but you still need to install the compiler yourself.

To compile your code you'll need to install the Java Compiler (javac) which is a separate program. You can install the Java Compiler by installing the Java Development Kit, which is a set of tool for developing Java programs.

Typically the Java Develoment Kit (JDK) instillation will set up your operating systems paths so javac will refer to a valid program after your restart VS Code and your consoles. If it still doesn't, refer to the answer linked my MikaelF's answer. You'll need to manually tell your computer where you installed the JDK.

Vera F W C
  • 208
  • 3
  • 11
0

only jdk can help you to compile java class;

open cmd type:"java -version"; if not have proper response(the version of jdk),you should download jdk from oracle and install it,and ofcourse add the bin directory like this(D:\workSoft\JDK8\bin) to the path environment;

if you had install the jdk correctly then visual studio code will compile the .java file to .class file automatically

Steven-MSFT
  • 7,438
  • 1
  • 5
  • 13