The whole core course works in your browser. This optional local step shows that the source files are ordinary Java, not code that only makes sense inside the website. You can download them, inspect them and run them with a Java Development Kit (JDK). The browser's engine follows a documented subset of Java 25, so JDK 25 is the closest reference environment for these lessons.
Download and inspect
Download the study planner or the earlier two-file session example. Extract a ZIP before opening a terminal in its folder. The planner contains Main.java, Planner.java, Session.java, PlannerTest.java, sample-input.txt and a README explaining its contract. There is no external dependency or build tool.
Use the official Java learning site for installation help. Install a JDK, not only an execution runtime, because javac is the compiler. A terminal is an app where you type commands and press Enter to run them. You can use Terminal on macOS, a terminal on Linux, or PowerShell/Command Prompt on Windows. Type each line below separately; do not type the code-fence labels. Check both tools in your terminal:
java --version
javac --versionIf either command is missing, finish installation or correct the terminal's PATH. PATH is the list of folders your terminal searches for commands. The JDK installation guide explains how to put its tools there. An editor plugin alone does not necessarily install a JDK. Open a new terminal after changing PATH. If setup is taking you away from Java practice, continue in the browser and return to this optional section later.
Compile, test, then run
Open your terminal in the extracted study-planner folder. Many file managers
offer an Open in Terminal action. Otherwise use cd (change directory) followed
by the folder's full path in double quotes; the actual path depends on where you
extracted it. Then compile all four source files and run the test entry:
javac Main.java Planner.java Session.java PlannerTest.java
java PlannerTestjavac creates .class files; it does not run main. java PlannerTest launches the compiled test class, with no .java suffix. After a successful compile, the test program should print All planner checks passed. Stop and read the error if compilation fails; otherwise old .class files could confuse your next run.
In a macOS/Linux shell or Windows Command Prompt, run the normal entry with the supplied input file:
java Main < sample-input.txtIn PowerShell, use Get-Content sample-input.txt | java Main instead. The file's
lines become standard input; the model still does not save a plan to disk. Without
redirection, a local terminal can provide interactive input until EOF; the
browser uses its prefilled box instead. README explains the relevant EOF keys.
Check your prediction
All planner checks passedThis gives you an installation-free reference while setting up local Java. The ZIP and file tabs come from the same maintained sources. If a later edit changes a rule, rerun checks in both environments.
public class Main {
public static void main(String[] args) {
String sourceName = "Main.java";
String compiledName = "Main.class";
System.out.println(sourceName);
System.out.println(compiledName);
}
}Check your prediction
Main.java
Main.classA .java file is source you edit. A .class file is compiled output. These are just explanatory Strings; creating these variables does not create files or invoke the compiler.
Your turn
Read the sample file to the end
Write a program that reads standard input line by line until there is no more input, then prints how many lines it read and the longest line. With the planner's sample-input.txt (already in the input box) it prints:
Lines: 6
Longest: ReadingRun it in the browser first. Then, if you set up a JDK: make a new empty
folder, save your program there as Main.java, copy sample-input.txt next to it,
and run java Main.java < sample-input.txt. The output should match. Finally
run java Main.java with no file, type two lines yourself and end the input
(Ctrl+D on macOS/Linux, Ctrl+Z then Enter on Windows).
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
// Read every line, then print the count and the longest line.
}
}Hint 1: the idea
The program can't know in advance how many lines there are: it keeps reading
while input remains. In the browser that end comes when the box runs out; with
< it comes at the end of the file; typing, it comes when you press the
end-of-input keys.
Hint 2: a first step
Use while (input.hasNextLine()) and read one nextLine() inside it. Get the
count right first, then add a longest String that starts as "" and is
replaced when a line's length() is bigger.
Show one solution
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int lines = 0;
String longest = "";
while (input.hasNextLine()) {
String line = input.nextLine();
lines++;
if (line.length() > longest.length()) {
longest = line;
}
}
System.out.println("Lines: " + lines);
System.out.println("Longest: " + longest);
}
}Lines: 6
Longest: Readinginput.hasNextLine() is what makes the same program work in all three places:
it turns false at the end of the input box, at the end of the redirected file
and when you type the end-of-input keys. > (not >=) keeps the first of two
equally long lines.
Change it and explain
Make a small source edit, compile again and rerun both the tests and the demo. Record the commands and expected output in your own words. Do not include your JDK installation, generated .class files or unrelated personal data in a project submission; the source and instructions should be sufficient.
The browser's multi-file mode follows source-launcher behavior and may leave unused helpers unchecked. Explicitly compiling all files locally can reveal errors in an unused source too. That is a difference in how you launched the build, not a rule that Java types work differently online.
Completion is saved in this browser only. It does not measure mastery.