Practice Java online
A free Java editor that compiles with javac and runs on a real Java 17 runtime, inside your browser. Write a class with a main method, press Run, and type your answers when your Scanner asks. Built with CheerpJ.
Java 17 · free · no sign-up · runs in your browser
Java practice problems for beginners
Each one opens in the editor above as a working program with something left for you to finish.
- problem 1
Greet me
Read a name and an age with a Scanner, then print one sentence that uses both.
- problem 2
Even or odd
Read a whole number and use % to say whether it's even or odd.
- problem 3
FizzBuzz
Count to 30 with a for loop, saying Fizz, Buzz or FizzBuzz for multiples of 3, 5 or both.
- problem 4
Average of an array
Loop over an array of test scores to find the total, then print the average and the highest score.
- problem 5
Times table
Read a number and print its times table from 1 to 12 with a for loop.
- problem 6
A bank account class
Finish a BankAccount class with deposit and withdraw methods, and refuse a withdrawal bigger than the balance.
A free online Java compiler that runs in your browser
- Java 17, compiled by javac: records, var, switch expressions and text blocks all work
- Scanner and System.in work: the program pauses and you type in the console
- ArrayList, HashMap and the rest of java.util ready to import
- Compile errors point to the exact line, and so do exceptions
- A loop that never ends can be stopped, and won't freeze the page
- Built with CheerpJ, so it runs on school Chromebooks with nothing to install
Java editor questions
Is this Java editor free?
Yes. It's free, with no sign-up, no ads and no tracking. Your code runs in your own browser and isn't sent anywhere unless you press Share to make a link.
Which version of Java is it?
Java 17, compiled by javac and run on CheerpJ, a Java runtime made for the browser (cheerpj.com). Records, var, switch expressions, text blocks and the whole standard library you'd use in school are there.
Does Scanner work?
Yes. When your program reads from a Scanner on System.in, it pauses and you type your answer in the console, then press Enter.
Does my file have to be called Main.java?
No. Write a public class with a main method, call it anything, and the editor works out the rest.
Why is the first run slow?
The first time, your browser downloads Java from CheerpJ and starts the compiler, which takes about 20 seconds. After that, compiling and running take a second or two, and the next visit is faster too.
Does it work on a Chromebook, iPad or phone?
Yes, in any up-to-date browser: Chrome, Safari, Edge or Firefox, including school Chromebooks. The first run downloads about 18 MB, then your browser keeps it, so later visits start fast.
Are there any limits?
A program can run for 10 seconds (time spent waiting for you to type doesn't count), and programs can be up to 20,000 characters. That's plenty for practice problems, school assignments and small projects.
Want a coach while you practice?
HopeCoders teaches Java 1-on-1 for all ages, from first programs to school projects. Every coach is background checked, and sessions happen in person across Greater Los Angeles, from Pasadena, Burbank and Beverly Hills to the South Bay, Long Beach and north Orange County, or online over Zoom.