This article was co-authored by Jessica Andzouana and by wikiHow staff writer, Nicole Levine, MFA. Jessica Andzouana is a Software Engineer based in the San Francisco Bay Area. With over five years of professional experience in front-end development, digital art, and design, she is passionate about emerging technologies such as blockchain and AI. Her background as both a programmer and artist, paired with a highly design-conscious mindset, provides her a fresh perspective and unique skill set to produce creative solutions in her field. She works at Alcacruz as a Software Engineer, and received a dual BS/BA degree from Santa Clara in Computer Science and Studio Art.
This article has been viewed 47,643 times.
This wikiHow teaches you how to turn your Java source code into an executable app using a local and online compiler. If you're using a computer, the most common way to compile Java code is using Java Software Development Kit (Java SDK) from the command line. If you're using a phone or tablet (or a computer without a compiler), you can use an online compiler like Codiva.
Things You Should Know
With the Java SDK installed, open your computer's command prompt to compile your Java program.
Use an online compiler for an easy and lightweight option to check if your code is working properly.
Online compilers often autosave, so you don't have to worry about losing progress if something were to go wrong.
Windows: Right-click the Start menu and select Command Prompt. If you don't see this option, type cmd into the Windows Search bar and click Command Prompt in the search results.
macOS: Click the magnifying glass at the top-right corner of the screen to open Spotlight, type terminal, and then click Terminal in the search results.
Type javac sourcecode.java and press ↵ Enter or ⏎ Return. Replace sourcecode.java with the name of your source file.[3]XExpert SourceJessica AndzouanaJessica Andzouana Software EngineerExpert Interview[4]XResearch source This compiles your source code into an executable file, which ends with the .class extension.
To see the name of the new file in the current directory, run the dir (Windows) or ls -a (Mac/Linux) command.
Navigate to https://www.codiva.io in a web browser. Codiva is an online Java compiler that's great for people who can't install a compiler locally—it can even be used on a phone or tablet.
There are a variety of online compilers out there if Codiva doesn't work for your needs. Some other popular options are Jdoodle, and OnlineGDB.
Create a Java source file and click Create. Java source files must end with the .java file extension. The new file will appear in project's tree, which appears in the right panel.
For example, if you're creating a Java program called HelloWorld, name the source file HelloWorld.java.
Write or paste your code into the editor. The code will compile in the background as you type. Additionally, it will display any code errors as they occur.
This article was co-authored by Jessica Andzouana and by wikiHow staff writer, Nicole Levine, MFA. Jessica Andzouana is a Software Engineer based in the San Francisco Bay Area. With over five years of professional experience in front-end development, digital art, and design, she is passionate about emerging technologies such as blockchain and AI. Her background as both a programmer and artist, paired with a highly design-conscious mindset, provides her a fresh perspective and unique skill set to produce creative solutions in her field. She works at Alcacruz as a Software Engineer, and received a dual BS/BA degree from Santa Clara in Computer Science and Studio Art. This article has been viewed 47,643 times.
1. Open the command prompt.
2. Change to the directory containing your code.
3. Type "javac (your source file)" and press Enter.
4. Type "java (compiled file name)" and press Enter.