Search code examples
javabuildsublimetext3windows-subsystem-for-linux

How to run or build a java program using wsl 2


I am trying to use wsl 2 to run java programs, and I will be writing the code in sublime text 3. I have already installed java in wsl 2, but don't know how to run a program through it built in sublime.


Solution

  • First, copy the java file to the linux system, the windows disk can be copied from the mnt directory enter image description here

    Make sure you have successfully installed the Java environment

    Use the javac command to compile the .java file, Use java command to execute .class file