Setting Up Your Development Environment

Framework Television Inc.
A free video tutorial from Framework Television Inc.
Learn with the folks from Framework Television
4.2 instructor rating • 49 courses • 288,045 students

Lecture description

In this video, Zachary shows you how to download an SDK and set up your space for developing Java.

Learn more from the full course

Java 101: Java Programming for Beginners

Learn the Fundamentals of Programming with Java. Start Coding Like The Pros.

07:37:26 of on-demand video • Updated October 2020

  • Set up the development environment
  • Troubleshoot errors
  • Work with integer variables
  • Work with floating point variables
  • Use Math functions
  • Work with char variables
  • Understand Java strings
  • Work with simple and complex conditionals
  • Use switch...case... break statements
  • Work with while and do...while loops
  • Create for loops
  • Work with standard arrays
  • Create multidimensional arrays
  • Code ArrayList Objects
  • Understand the map data structure
  • Create simple and complex custom functions
  • Modeling with Object Oriented Java
  • Creating class constructors
  • Understanding inheritance
  • Creating and using abstract classes
  • Working with date/time classes
  • Working with string classes
  • The exception class
  • The object class
  • Primative classes
  • Writing and reading data via file I/O
  • Serializing classes
  • Creating GUIS with swing
  • Event Handeling
  • Reading and parsing XML Data
  • Writing XML data
English [Auto] Welcome back. In this video we're going to write our first job a program. But before we can start coding away we need to set up an environment that is Java development friendly to start off this process. Let's download a Java development kit or a Java SDK. This kit contains libraries and executables that allow us to do lots of different things with Java code. Most importantly with our SDK installed we'll be able to compile Java code and then run completed job of programs. You may already have Java installed on your machine. However unless you've explicitly done it you probably haven't installed a Java SDK. The version of Java your average user has installed on their machine is called the Java runtime environment or JRD. This allows the execution of job programs and Java programs won't run on environments without the JRD installed. But the Jarry doesn't contain any real development tools which were going to need. The good news is a Java JRT and a Java SDK can exist harmoniously. The Java JRA is really just a subset of the SDK and so if we only have the Java development kit installed which we're about to download We're also going to be fine. If you have downloaded the Java development kit in the past when we actually go to install this kit Javal will let you know that it's already installed and you can skip this portion of the video for everyone else. Let's download ourselves a development kit to begin with. Pause the video and navigate to this. You are al at the top of my web browser. OK we're going to be using the Java SC or standard edition development kit maintained by Oracle to acquire this kit. We simply go to the downloads tab express that we would like the JDK. Scroll down. Check out the license agreement. Might be another good time to pause this video eventually except the license agreement and then we're going to download the version of the SDK that's appropriate for our operating system. For me that's the sky. Once your download has completed install it as you would any other program choose the default options when appropriate and make sure to take note of the directory to which you install your development kit. OK with our Java development kit installed. We technically have all the tools we need to start writing job programs. However we'd have to compile them through a command line which can look a little different on different operating systems. So to keep everything simple let's start learning Java by writing our Java code in an integrated development environment or ID. This is a software program of its own that helps us write compile and run Java programs. We're going to use the net beans ID which is awesome because it is free open source and is going to operate just about the same on Windows Mac and Linux environments to acquire this ID head to the RL. Once again at the top of my web browser. And then you'll see this page because we've downloaded the Java standard edition development kit. That's the version of net beans that we're going to download here. NET beans should start our download automatically but if it doesn't we can click here once again. We're going to install net beans as we would any other program choosing default options when appropriate. Most likely. NET beans will locate the Java development kit on our machine. If it doesn't it will prompt you for the directory in which you installed the Java development kit. Hopefully you got net beans installed and booted up without any hassle and now you you're ready to write some java code. So let's do that. We're going to go file new project in net beans and choose Java application as our project. Make sure this create main class option is unchecked as this will create for us a essentially blank project. And give your project the name. Hello world. Here you can declare what location you'd like. The projects folders to live in. Once you've done that click Finish and net Beane's will set up a file system for us. We can navigate this file system just like we were in a standard file system Explorer explore the source packages. File is where we'll be writing our code today and you'll notice under this library's file the JDK is linked allowing us to access all of its many library resources. All right hopefully you got net beans installed and booted up without any issue and now you're ready to write your first job program. So let's do that. NET beans will manage the file structure of our programs for us. But first we need to tell him that beams that were ready to begin a new project to do this we like file new project and choose a job application. We're going to need to give our project a distinctive name. Let's call this one hello world and then we can choose a location to put the file because this is our very first java program. We should probably start from as close to scratch as possible. So let's uncheck this create main class option so that net penes gives us pretty much a blank project. And then we'll click Finish You should see this project's files and services tab like I have here. Let's look in the files tab. Whereas the projects tab is a bit of an abstraction. The files tab shows us what's actually contained within the file system where our Hello World Project lives. Most importantly this source file here has no files in it. That's because there is no source code associated with our project. And so right now it won't do anything to remedy that. Let's right click on this file choose new and Jobbik class. We're going to name our Java class. Hello world. Just like the name of the project because it is our main class where the program should be entered and start from. Everything else is going to work just fine here for now. So let's click Finish and netbios will create Hello World dot Java for us a dot job a file is essentially a text file but it should only contain Java code and comments. When we told Matt Beane's to make this file it took some liberties and added some code for us already. You'll notice that some of the contents of this document are completely human readable. These are what we call comments. Any text that appears in a job file between this backslash star opening bracket and star backslash closing bracket will be completely ignored by the compiler. We can write whatever we would like in here and it will not affect how our program operates. For now let's just delete these comments so that we can deal purely with our job code. Java code like the English language is read top down and left to right. Even if our project contains many files and many classes we still need to start reading and executing our code at a specific point. We named this file and class hello world the same name as our project because we would like it to be special and contain the public static void main method. That's quite the mouthful of jargon for now. Just type it out and know that this is the area of our code from which our jobs program will begin reading and executing in fact we have to add a little more jargon in here string bracket bracket args. Once again this will become much clearer as we begin to learn Java just know this is the starting point for our jobs program are followed by opening and closing brackets. One of the great things about working in an ID is that it will highlight which brackets correspond to each other. The brackets allow us to place code within other areas of code for example. Our main method is contained within the hello world class and the Java code which we're about to write and execute is going to be contained in our main method this line for right here which currently contains nothing will be where our program looks to start reading and executing Java code. Our goal with this hello world program is pretty modest when it runs. We'd like it to print some text to this output box at the bottom of our screen. When we downloaded the Java SDK we acquired a library of useful functions one of which will do just this. This is the print. Or print line function. When our Java code executes over this function which it will do right away because it's the first function in our main entry point the Java code will print some words to our output box. Functions are followed by an open and closed parentheses. Inside these parentheses we put information that the functions need to complete their task print line of course needs to know what we would like it to print. In Java a line of text is contained by two double quotation marks and we call it a string. Let's have our program print Hello world. You might have noticed that Beane's has been yelling at us for a little bit. There's a light bulb and red dot here and some red jittering under our text. A lot like we made a spelling error in some text editors and that's really what we've done. We've made a syntax mistake. There's something clearly wrong with our Java code and netbios knows it. There's actually two things wrong. The first is that our code doesn't and with a semi-colon job doesn't do a good job of reading spaces and carriage returns so we need to put semi-colons at the end of every functional line of code for the same reason that a Morse code operator would send the message stop at the end of every line. Now met beans has become a little more satisfied the jittering has decreased but there's still something wrong. The issue is that functions in a programming language just like files on a computer have a location where they exist. NET beans isn't sure where to find the function print line that we've been tempted to use so we simply need to tell net beings where this function exists. The full path to the print line function is systemd dot out of print by let's get rid of these extra spaces I created there not because they would affect the way our program runs just because it doesn't make it look quite as nice. And now we've written our hello world program. So what do we do with this. Well as we know our computer can't read this Java code directly it must convert it into a computer readable language so executing this code becomes a two step process. First we're going to ask net beads to build our project. This means that all of the code within our project will be compiled and converted to computer readable code in a essentially computer readable project. When we press the build button we'll see a bunch of text in our output box down here and hopefully this nice build successful and then the time it took to build the project once we built our project we can press this run button right here to execute our code and our print line statement. That beams will then give us this pop up box here. When you execute a program outside of an idea you execute it by launching one of its executable files because we're in an integrated development environment right now. NET Beane's wants to be sure which of our files we would like to be the entry point of our program. We only have one option here because we've only written one Java class so let's confirm for net beans that hello world is our main class and the main function in hello world will therefore be where we start executing our job a program. Then when we hit OK our output box will tell us the program has begun to run and our program then prints hello world to the output box as we intended. And there you have it. Now we're Java programmers. Of course there's more than a little bit less to learn. In fact hello world in Java is probably the scariest program you'll ever write. Java is extremely powerful. And the reality is we simply can't hope to appreciate all of its intricacies while writing our first program. The really good news is that from this point on we need to take far fewer leaps of faith and we can begin to build a very solid understanding of Java by taking a step by step approach. I'll see you next time.