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

Guide to Using the 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

hint
This lesson goes over the basics of the GDB Online IDE for Java. GDB 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.

1. Introduction to GDB Online

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 GDB as the IDE for Java. GDB 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.

GDB can be used to run code that has been created in basic online text editor. There is no need to copy code or make changes to the underlying environment. Additionally, GDB will 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 GDB account is not required, having one allows for the use of all of the features including saving work so you can return to it.

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 GDB User Account

step by step

1. To get started, access the following site:

https://www.onlinegdb.com/

2. Click “Sign Up” and create a GDB user account. You will need to verify your account before all account features will function.

Screenshot of Sign Up Button Location

3. To create a new project select Create a New Project button, then select the correct programming language by choosing Java from the dropdown menu in the top right corner. If you forget this step, it will alert you that you must choose a language.

5. To save your project, if you plan to come back and work on particular program, click the Save button. Once you provide a name and hit the save button it will appear in My Projects tab.

3. The GDB IDE

The IDE across the top has 9 buttons.

Screenshot of GDB IDE and buttons

Let's look at the details of these buttons:

Button Description
New File Creates new files. Later in the course we will need multiple files, and this button will be used at that time.
Upload File Allows uploading of files, which we will not use in this course.
Run The most important button executes the code you put in the text editor.
Debug Does not work for this IDE for the programming language Java.
Stop Terminates code that is not functioning properly or running continuously
Share Generates a URL that can be shared with others to see your code. This will be used in the end of course to share your touchstone project.
Save Saves your code to your Projects. If you haven't yet saved you will be prompted for a Project name.
Beautify This feature can be useful as it allows the spacing and indentation of your code to modified to make code more readable.
Download This feature allows you to save a copy of your code on your own computer. It is not required for this course but is helpful if you plan to keep your own backup of any projects.

3a. Main Pane: Code Editor

By default, the main pane displays the code editor. You will spend the majority of your time working in the code editor window. Java code is written and edited in this tab. A Main.java file is listed directly above the code editor and displayed in the code editor tab by default as shown by the red arrow. The Main.java file is automatically created for you when you create a new project.

Screenshot of the GDB IDE Code Editor panel

3c. Bottom Pane: Input/Output Console

The pane on the bottom of the workspace is the input/output console. This is the section where when the code is run the output is presented.

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 GDB application, let’s set up your first program.

try it

Directions: In the GDB a new Java file named Main.java is automatically made as previously shown.

Rename the file to Hello.java:

Click on the 3 dots by Main.java file. Then click on Rename.

This will open a new window that allows you to type in the new filename. Capitalization and the file having .java extension are very important. If you make mistakes the code will not run.

In the code editor, type in the following code (in GDB most of this code already exists but you can note on Line 1 it now should be public class Hello . You may also delete all the text that is above the code:


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

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

Screenshot of the GDB 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.

Click the Run Button to see the code execute which will appear in the bottom Input/Output Console pane.

Screenshot of output in the GDB Console pane at the bottom of the screen

reflect

What happened? The program was compiled and executed in GDB. 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!

summary
In this lesson, you set up a GDB account. You were introduced to the GDB IDE (Integrated Development Environment), including the buttons, which consists of the Run, Share and Stop; the main pane, which is the code editor; and the bottom pane, which is the output/input console;. You explored how GDB 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!

SOURCE: THIS TUTORIAL HAS BEEN ADAPTED FROM (1) “JAVA, JAVA, JAVA: OBJECT-ORIENTED PROBLEM SOLVING, THIRD EDITION” BY R. MORELLI AND R. WALDE. ACCESS FOR FREE AT CS.TRINCOLL.EDU/~RAM/JJJ/JJJ-OS-20170625.PDF. LICENSE: CC ATTRIBUTION 4.0 INTERNATIONAL. (2) “PYTHON FOR EVERYBODY” BY DR. CHARLES R. SEVERANCE. ACCESS FOR FREE AT PY4E.COM/HTML3/. LICENSE: CC ATTRIBUTION 3.0 UNPORTED.

Terms 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

Libraries/Library

Prewritten code collections that you can use when developing a program