Use Sophia to knock out your gen-ed requirements quickly and affordably. Learn more
×

1.1.5 Guide to Using IDE

Author: Sophia
what's covered
In this lesson, you will review the Java integrated development environment that will be used in this class. Specifically, this lesson covers:

Table of Contents

before you start
This lesson goes over the basics of the Replit IDE for Java. Replit is frequently updated and may look different than the screenshots depicted below. If you find yourself stuck at any point in the process, you are encouraged to visit the support page maintained by the Replit team for the most current account creation and usage guidance.

hint
If needed, here are some Tips for Accessing Replit in your Sophia course.

1. Introduction to Replit

There are different ways to write your code and run it when creating the program. For many languages, there is the option to use an Integrated Development Environment (IDE) to write the code. An IDE can be viewed as a text editor that has additional functionality. This allows developers to perform additional tasks that simplify the workflow of the development process. Individuals and organizations may have different preferences of which IDE they like to use.

This course uses Replit as the IDE for Java. Replit has some unique features. Replit is a tool that is completely run through a browser. This means it can be used from any computer, tablet, or mobile device to write, build, and run code.

Replit can be used to run code that has been created in the online Shell. There is no need to copy code or make changes to the underlying environment. Additionally, Replit can fully manage the environment that is used to build and run code. This means that the right version of Java is not important. It is also not necessary to confirm the correct libraries, or prewritten code.

hint

While a Replit account is not required, having one allows for the use of all of the features. This account allows access to features that will be required for the completion of work in this course.

term to know

Integrated Development Environment (IDE)
A text editor that has additional functionality to allow developers to perform some additional tasks to simplify the workflow of the development process.


2. Creating a Replit User Account

step by step

1. To get started, access the following site:

https://replit.com/signup

2. Click “Continue with email” and follow the prompts to create a Replit user account.

3. Once the account is created, click on the “+ Create Repl" button in the top left. This will allow the creation of a new Java project.

Screenshot of the create new Repl button.

4. The Create a Repl window appears. Select “Java” from the Template dropdown menu of languages. If Replit has been used previously for Java coding, Java may appear at the top under Favorites.

Screenshot of the create a repl window.

5. By default, a random project name will be generated in the Title field. Please change the default name to something more meaningful to your project. For our coding examples in this course, we have named our Repl as “Intro_to_Java”.

hint

Giving your project the same name, "Intro_to_Java", will make it easy for you to follow along with the examples.

Screenshot of the Replit create a repl window with generic project name in the Title field.

key concept

It’s important to note that by default, the Repl will be public. This means that this project can be accessible by anyone on the Internet. Although this can be very useful when it comes to collaboration and sharing of code, care should be taken when using personally identifiable information in your projects. This includes adding passwords to your project code.

6. Finally, select “+ Create Repl” to create the project.


3. The Replit IDE

The IDE consists of three (3) main panes and a Run button. The main elements can be reviewed in a left-to-right order.

Screenshot of the Replit IDE application.  The three panels are visible.

hint

These tabs and panels can be dragged around to reposition them on the workspace.

3a. Left Sidebar: Files and Tools

The left sidebar consists of a file tree and tools selection menu.

Screenshot of the left sidebar of the Replit IDE with the files menu bar visible.

The file tree allows you to create, edit, organize and delete files in your project.

Screenshot of the left sidebar of the Replit IDE with the files menu bar visible.

The tools menu contains a listing of all tools used to increase productivity. In general, each tool menu item opens a new tab on the right-hand side of the workspace. Although the tools menu has quite a few features, it is not critical to know what they all do. In most cases, only a small selection of features are used within the IDE for any given program.

Let’s cover the main tools used in projects for this class.

Feature Description
Docs This feature opens a documentation tab on the right-hand side of the workspace. You will find helpful guides and videos here.
Deployments Create a production build of your project so people can use it without being interrupted by changes in progress.
Git (Version Control) This isn’t one that is needed right now, but if there is a need to track changes and roll back to prior versions (similar to Track Changes in MS Word), using this feature will allow it to be done.
Debugger This feature can be very helpful to create breakpoints in the code. It also allows users to step through the code one line at a time—but more on that in a future tutorial!
Shell The shell shows the output of the Repl if you run it.
Packages These packages allow the import of code and functionality that hasn’t been built but could be added to the program. For example, when building an image gallery and there is a need to create an image carousel that rotates, a package can be imported that already has that feature which will make it much easier to build and implement. Note that Replit packages are not the same thing as Java packages.
Secrets (Environmental Variables) Even if Replit is set up to be accessible by the public, variables can still be stored in a manner that’s hidden away from everyone else but still makes use of them in the Replit. Using this feature will allow you to hide secret information like passwords while still being able to use them in the Repl.
User Settings This feature can be very useful as it allows customization of the layout, color scheme, font size, and other features.
Database This feature allows quick database key commands.
Unit Tests This feature allows you to run tests.

think about it

Throughout the course, you will be using the default User Setting options. However, if you would like to change those, you can do so.

3b. Middle Pane: Code Editor

By default, the middle pane displays the code editor tab. You will spend the majority of your time working in the code editor tab. Java code is written and edited in this tab. A main.java file listed in the Files area of the sidebar and displayed in the code editor tab by default. The Main.java file is automatically created for you by Replit when you create a new project. The code that is entered in the code enter is saved to that main.java file.

Screenshot of the Replit IDE Code Editor pane

3c. Right Pane: Output Sandbox

The last pane on the right side of the workspace is the output sandbox. The console tab and the shell tab are displayed by default. This is the section where code is run and the output is presented.

Screenshot of the Replit IDE Output Sandbox pane.

3d. Above the Panes: Run Button (Do Not Use With Java)

Above the main panes, there are additional functionalities. However, one of the more important functions is the run button. It is located in the middle of the pane at the top. Using the Run button often exposes issues with the sandbox configuration.

hint

When running Java applications, users should not use the Run button. The Java command should be used inside of the Shell tab of the output sandbox window.

Screenshot of the Replit IDE Run Button

term to know

Libraries/Library
Prewritten code collections that you can use when developing a program.


4. Running a Program

Now that you are set up with an account and have had a tour of the Replit application, let’s set up your first program. To get started, enter some code and test it and see what happens.

try it

Directions: In the Replit Files panel, click the ‘java’ folder at the left and then click the New File icon. This will create a new Java file inside the ‘java’ folder where the Main.java file is created by default. We will follow this process of creating new Java files inside the ‘java’ folder throughout this course.

Screenshot of the Replit New file Button

Name the file Hello.java (capitalization and spelling are important).

Screenshot of the Replit Hello.Java.

hint

If you have not closed the Main.java editor tab, the Hello.java code editor tab will be placed in a pane at the far-right side of the workspace.

In the code editor, type in the following code:


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

The following is a screenshot of the Replit IDE code editor screen with “Hello World”.

Screenshot of the Replit IDE code editor screen with the text Hello World displayed.

reflect

Notice that on the left of the lines of code there are line numbers being displayed. These are not part of the code. They indicate the line numbers. This will be useful in the future.

Let’s try running a program.

try it

Directions: Locate the Shell tab. By default, it will be located on the right side of the window.


Screenshot of the Replit IDE code editor screen with the shell visible

Type the following command to run the program:

java src/main/java/Hello.java

While running the program, we need to include the complete file path (src/main/java) along with the file name. We will be using this command to run the programs that will be created in the ‘java’ folder in this course.

Alternatively, if the new Java program file is created in the root directory (IntrotoJava) then the program can be run without using the file path in the command.

EXAMPLE

Screenshot of the location of the java folder.

However, creating a new Java program file anywhere other than inside the ‘java’ folder may show warning as can be seen in the following screenshot.

EXAMPLE

Screenshot of the run command showing the complete path.

So, it is recommended that all new Java files be created inside the ‘java’ folder (which is the default classpath) and the run command for the program should include the complete path.

EXAMPLE

The following is a screenshot of the Replit Shell tab with the complete path visible:

Screenshot of the Replit IDE code editor screen with the command visible in the Shell tab.

reflect

What happened? The program was compiled and executed in Replit. In doing so, since our code didn’t have any errors, it displayed the result of the print command on screen. Congratulations! You have written your first Java program, built it, and run it. That is how easy it is to run it!

Screenshot of the Replit IDE code editor screen.

hint

Be aware that unintentional line-wrapping may occur in the code samples throughout the course depending on your display. A screenshot of Replit is typically provided following code samples for clarity.

watch

The overall process of a new Java file creation and running the file is demonstrated in the following video.

summary
In this lesson, you set up a Replit account. You were introduced to the Replit IDE (Integrated Development Environment), including the left pane, which consists of the menu bar and the files and configuration pane; the middle pane, which is the code editor; the right pane, which is the output sandbox; and the additional functionalities above the panes, such as the run button (which should not be used when running Java applications). You explored how Replit will provide a working platform to try, write, test, and debug code while working in this course. At the end of this tutorial, you wrote and ran your very first Java program!