Java: A First Look
Java is a very popular and powerful type-safe language, used in many areas including general software development, large complex enterprise systems, mobile development, IoT devices, etc.
Knowing and understanding Java will help you succeed as a developer within many industries. Well, Java is more than just a software language. It’s a platform that provides many features. The Java platform not only runs on computers but it is equally at home within Cars, Cards, Rings, PDAs, and many other physical devices. The Java platform was developed early on with the explicit intention of being a portable technology, being agnostic of any underlying operating system - and therefore being able to run in as many different places possible. This is and has been and always will be one of the main motives to consider investing in Java.
This training Course introduces you to the Java Platform, the Java SDK, and Eclipse as an IDE for creating and managing Java software applications.
You will learn:
- What Java is
- The Java tooling and which tools are used for tasks such as compiling, running, and documenting Java programs
- The different versions of Java
- The JDK structure
- How to create a simple Java class
- How to compile and run a simple Java application using the javac and java tools
- Eclipse for coding Java programs
- A basic understanding of software development
- A basic understanding of the software development life cycle
- Software Engineers interested in learning Java to develop applications
- Software Architects interested in learning Java to design applications
- Anyone interested in basic Java application development and associated tooling
- Anyone interested in understanding the basics of the Java SDK
- [Instructor] Okay, welcome back. In this lecture, we'll introduce you to the Eclipse IDE. The key objectives of this lecture will be for you to understand what the Eclipse IDE is, and how it can be used to develop Java applications, understand the various views within Eclipse, and understand how to navigate within Eclipse to write, debug, and run Java applications. So what is Eclipse? Eclipse is an Integrated Development Environment written in Java and, more often than not, used to write Java. Eclipse was originally an IBM creation developed as a replacement for their Visual Age for Java product. In 2001, IBM decided to give Eclipse to the development community as open source. Eclipse is tightly coupled to Java since it is written in Java and, as already mentioned, is primarily focused on Java development.
After 13 annual Eclipse releases by the open source community, the faster release cadence of Java, and the fact that annual releases are now considered the legacy way of doing things, things had to change. Therefore, by introducing a quarterly release schedule for Eclipse, new features can be provided to the community a lot, lot faster. Eclipse itself provides two main conceptual levels for application development, the Workspace and the Workbench. The Workspace is a physical location of projects, packages, files, and many other things. The Workbench provides perspectives, editors, and views to manipulate the files in the Workspace. Note that any configuration settings, preferences, servers, and history are specific to a Workspace. Creating a new Workspace will create a new context for further work. Many artifacts associated with the Workspace can be exported and then imported into other Workspaces.
When you install Eclipse and set up you own Workspaces, carefully organize the underlying file system structure. For example, things to consider. Consider placing development resources together in a path that is close to the root drive. Ensure that paths to Workspaces do not include any spaces or white space. This tip alone, will prevent a lot of pain down the road when developing and compiling Java applications, and consider using different Workspaces to organize major projects. Workspaces help to ensure clean, well-separated, and partitioned development environments. With multiple projects organized into separate Eclipse Workspaces, you can easily swap between them via the file switch Workspace menu option. In the background, an Eclipse Workspace will synchronize itself with the underlying file system structure. An Eclipse Workbench organizes a number of different development tools, each providing a different perspective and behavior to manage the resources contained within a Workspace. In the Workbench example presented here, we can see that it is composed of the following views: the Package Explorer View, the Java Editor, the Task List View, the Outline View, and the Problem View. Breaking the Workbench down further, we see that it has three main types of visual tools that aid the developer as he or she goes about developing their Java application. Perspectives is a group of views and editors appropriate for a specific task, such as debugging a Java application. Editors are a type of component that developers can use to create and modify files, and Views are a type of component that provide information and/or extra metadata about a selected resource. Within Eclipse, different views can be called upon by the developer. This is performed by navigating to the show view menu option. Having done this, a list of available views is displayed. Some example common views that are often used are, the package explorer, navigator, console, outline, properties, problems, tasks, and the bookmarks menu. A collection of views can be arranged into a named Perspective. A Perspective contains an initial collection of views organized in a particular arrangement, focused on achieving a particular development task. The default Perspective is called Java. Furthermore, each different Eclipse Perspective provides quick and easy access to a pre-configured arrangement of views. Each view shows something of interest to their perspective. Finally, multiple views can be arranged to be visible at the same time within the Workbench window.
Let's now review some of the more commonly used views. The Navigator View provides a file-based organization of various coding files. Other views may give an application-based or project-based representation of code contained within the coding files. Within the Navigator View, you are presented with files, which correspond to the files on the file system, folders are like directories on the file system, and projects, which are used to organize all of your resources and also for version control. When you create a new project, you assign a physical location for it on the file system. A third party party SCM, source control manager, may be used to properly share in version control project files. The Outline View provides you with an overview of the key elements that make up the resource that is currently being edited and allows you to quickly and easily navigate through your resource using a tree model for organizing related elements. The Property View provides you with a list of properties associated with the currently selected resource within the Navigator View. When you click on a resource in the Navigator View and then click on the properties tab on the bottom of the screen, you can view the properties associated with that resource. The Task List View contains a list of task items to remind you of tasks you need to perform and complete within your project. You can manually add tasks yourself and is a great way to ensure that you manage your implementation requirements. The Problems View is where you hopefully don't have to spend too much time in. Regardless, it is good to know that it exists, and that you should consider it one of the most important Views within Eclipse. When it comes to debugging and troubleshooting your own Java applications, errors and warnings are automatically added to the problems view and by simply double-clicking on an entry, you will be taken directly to the location of the problem within the Coding View. Additionally, right-clicking on the left side icon will provide you with quick fix options. Compiler errors are a fact of nature when developing your Java code within Eclipse. You will constantly get feedback as to whether the current program compiles or not. Though Eclipse editor provides you with constant, real-time compiler feedback as to whether your current code base contains coding problems, consider this one of the real benefits that an IDE provides over writing raw Java code in a vanilla text editor without such features. These visual highlights should be embraced, as they will constantly guide you to correcting your code base as early as possible. Often, the visual highlights will be accompanied with suggested fixes, making your life as a developer even easier.
Every resource type has a default editor that is associated with it based upon the file extension. To open a file with another editor besides the default, right-click on the file and select open with, then select the editor you would like. Perspectives are a way to look at different facets of the same project. The Workbench window can have several different perspectives opened, but only one of them is visible at a time. Perspectives are created to match different development roles or tasks, such as editing or debugging. As seen here, Eclipse is installed with a default suite of perspectives. Example perspectives by role or task are: development uses the Java Perspective, debugging uses the Debug Perspective, collaboration uses the Team Synchronizing Perspective, and XML editing uses the XML Perspective. Perspectives can be altered, updated, and saved. New views can be added to an existing perspective, and existing views within a perspective can be altered themselves. For example, by double-clicking the title bar to maximize the view, by dragging views to other panes, and/or even stacking a view behind another view within the same pane. Deeper customizations can be performed by opening the customize perspective option. The customize perspective option allows you to set toolbar and menu visibility options for the current perspective. Projects are the top level construct for organizing all resources. A project is made up of many files and folders. Different kinds of projects have different structures. For example, when comparing a Java project to a Java EE project, the corresponding project will render differently. Plug-ins often add new types of projects. For example, JBoss adds Hibernate and Seam.
To configure a project's properties, switch to the Project Explorer View, right-click on the project's name, and select the properties item. A Java project, for example, contains all of your Java files. It establishes a build path used to compile all source files. That facilitates package and class creation and organization. It provides a Java source code editor, complete with Intellisense and syntax highlighting. And, it provides an ability to compile and debug. When writing code within the Java editor, Eclipse can provide coding assistance in the following two ways. Automatically, when you're writing code, Eclipse provides near real-time assistance by offering up autocomplete suggestions, and manually, when you're writing code, you can pause and request assistance by using the Ctrl + Spacebar key sequence. Okay, that completes this lecture. See you shortly in the next one.
Jeremy is a Content Lead Architect and DevOps SME here at Cloud Academy where he specializes in developing DevOps technical training documentation.
He has a strong background in software engineering, and has been coding with various languages, frameworks, and systems for the past 25+ years. In recent times, Jeremy has been focused on DevOps, Cloud (AWS, GCP, Azure), Security, Kubernetes, and Machine Learning.
Jeremy holds professional certifications for AWS, GCP, Terraform, Kubernetes (CKA, CKAD, CKS).