Join David Gassner for an in-depth discussion in this video Using the exercise files, part of Java 7 Essential Training.
- This course is accompanied by exercise files that you can use to follow along with the demonstrations. I've copied the exercise files to my desktop, but you can place them anywhere on your hard disk. The exercise files are organized by chapter. Within each chapter, you'll find a number of subfolders, one for each video for which there's a live demonstration. For those videos where I'm only showing slides, there is no subfolder. Within the subfolder for that video, you'll find a project folder.
And, for most of these folders, there's a source folder under that, and under that, a series of java package folders. You'll find the actual java code under com, example, java. And, as you'll learn in the course, that's the equivalent folder structure to a java package, a concept that's used to organize java code. These projects are designed to be imported into IntelliJ IDEA. I'll show you how to do that using the most recent version of IntelliJ IDEA community edition, Version 14.1.3.
From the welcome screen, I'll click on import project. Then, I'll navigate to my Exercise Files folder to the Chapter folder, and to the subfolder for that video. Then, I'll choose the actual project folder. Make sure that you don't choose any of the parent folders above this; this is the folder that you want to import. Notice that it has a source folder underneath it. That's what marks it. I'll click OK. Then I'll see a series of dialogues. On the first dialogue, accept the default to create the project from existing sources.
And click Next, and then you can accept the project name. If you prefer to change the location, you can do that at this point, but I recommend keeping it the same. On the next screen, IntelliJ IDEA tells you that it's found your source files under the SRC folder, that's the standard location for IntelliJ IDEA projects. Keep on clicking Next until you get to this screen, and click Finish. And that imports the project and creates a number of other files and folders that you'll need.
You can then open the project from the project window, and you'll find the source folder there. And you'll see that the package directory structure has been flattened, so it's shown as just a package. And from there, finally, you can open the java code. From here, if you want to get back to your folder in Finder or Explorer, you can right click on the project and then choose Show in Explorer on Windows, or Show in Finder on Mac. And that'll take you back to the exact same place.
Notice that there's now a file with the .iml extension, and a folder named .idea. On Windows you'll see this folder clearly, while on Mac, it'll probably be hidden. I'll go back to this step and I'll run the application for the first time. The first time you want to run the code, you'll need to make sure you've opened the main class. That's the class that has the main method in it. And then click into that class. Then go to the menu and choose Run, and then Run again.
Choose the item with the class name and click it, and that should run the class for the first time. That creates something called an edit configuration. From there, you can run by going to the menu and choosing Run, Main, or, as I'll show you later, there's a toolbar that has a number of icons, and you can click this Run button. But, again, you can only do that after you've run the application for the first time. So that's how to use the exercise files in IntelliJ IDEA.
It's also possible to open these exercise files in Eclipse, although I won't be using Eclipse during the course. For example, I'll go to my Exercise Files folder, to 04_05, and I'll use this project, Math. Now, I'm going to copy the location of this folder to my clipboard, and in Windows that's easy to do. You just click on the folder icon, and then copy the string that appears. Then I'll go back to Eclipse, and I'll say File, New, Java Project.
I'll set the name of the project to Math, then I'll uncheck the option to use the default location, and I'll paste in the location of the project. I'll make sure that I'm pointing to the actual project folder, and not to its parent folder. Then, I'll just click Finish. Eclipse, just like IntelliJ IDEA, assumes that your source files are in an SRC sub folder, and from there, you can open your files and do whatever you need to do. So that's a look at how to use the exercise files in both IntelliJ IDEA, which I'll be using throughout the course, and in Eclipse.
- Understanding the history and principles of Java
- Installing Java, IntelliJ IDEA, and BlueJ
- Creating a Java project
- Working with variables, values, and expressions
- Working with object data types
- Building, comparing, and parsing strings
- Debugging and exception handling
- Creating loops and reusable code
- Passing arguments by reference or value
- Using simple and complex arrays
- Creating custom classes
- Understanding inheritance and polymorphism
- Managing files with Java libraries
- Documenting code with Javadoc
- Packaging classes in JAR files