Skip to main content

Writing quick Java applications with VSCode

We write/run robot code using gradle, but how can you develop a single file? Or maybe a couple files with some classes? This tutorial will show you how.

Step 0: Ensure you have FRC VS Code installed

You should see a program on your computer called "FRC VS Code 2022" or alike. If not, follow the WPILib Installation Guide to install it.

Step 1: Create a folder

In your documents folder, create a folder called "Robotics Offseason 2023".

Step 2: Open it in VSCode

Open up FRC VS Code, and open up the folder you just created. You can do this by either navigating to File > Open Folder..., or you can click the Open Folder... button on the Getting Started page if you don't already have a project open

VSCode Open Folder

Step 3: Write a main class

Create a new file in your folder such as "Counting.java". This should relate to the project you're trying to solve, such as "CardCounter" or "MonteCarloSampling". Put the following code block into the java file you just created, replacing "Counting" with the name that your picked for your file:

public class Counting {
public static void main(String[] args) {
System.out.println("Hello world");
}
}

Step 4: Run it

After you added a class and a main method to a java file, VS Code should detect it as a runnable section and show you the "Run" and "Debug" adornments. Click on "Run" and you should see your program executed in a terminal window at the bottom of your screen.

VSCode Run Main Method