Discover millions of ebooks, audiobooks, and so much more with a free trial

From $11.99/month after trial. Cancel anytime.

IntelliJ IDEA Essentials
IntelliJ IDEA Essentials
IntelliJ IDEA Essentials
Ebook471 pages4 hours

IntelliJ IDEA Essentials

Rating: 0 out of 5 stars

()

Read preview

About this ebook

Starting with a walkthrough of the main workspace, you will get up and running with IDEA from the word go. You will learn how to exploit IDEA's software development tools and use the various product features such as source code control, the debugger, and the many code generation tools.

You will then move on to advanced topics such as how IntelliJ helps in version control, managing change lists, viewing differences and changes, and reverting changes. You will also learn how IDEA can be used for agile development and web development, as well as its integration with frameworks such as Gradle.

Complete with tips and tricks, this book will make sure that you have an in-depth and extensive knowledge of informed programming.

LanguageEnglish
Release dateDec 22, 2014
ISBN9781784398699
IntelliJ IDEA Essentials

Related to IntelliJ IDEA Essentials

Related ebooks

Hardware For You

View More

Related articles

Reviews for IntelliJ IDEA Essentials

Rating: 0 out of 5 stars
0 ratings

0 ratings0 reviews

What did you think?

Tap to rate

Review must be at least 10 words

    Book preview

    IntelliJ IDEA Essentials - Jarosław Krochmalski

    Table of Contents

    IntelliJ IDEA Essentials

    Credits

    About the Author

    About the Reviewers

    www.PacktPub.com

    Support files, eBooks, discount offers, and more

    Why subscribe?

    Free access for Packt account holders

    Preface

    What this books covers

    What you need for this book

    Who this book is for

    Conventions

    Reader feedback

    Customer support

    Errata

    Piracy

    Questions

    1. Get to Know Your IDE, Fast

    Comparing the various editions

    Installing IntelliJ IDEA

    An overview of the workspace

    Tool windows

    View modes in tool windows

    Pinned Mode

    Docked Mode

    Floating Mode

    Split Mode

    Multiple views in tool windows

    Navigating inside the tool window

    Tool windows set up for a specific project

    Editor tabs

    Crafting your settings

    Searching for options

    Setting keyboard shortcuts

    Colors and fonts

    Picking your plugins

    Configuration tips and tricks

    Exporting and importing settings

    Sharing settings

    Tuning IntelliJ IDEA

    Summary

    2. Off We Go – To the Code

    What is a project?

    Project structure and configuration

    Comparison of Eclipse, NetBeans, and IntelliJ IDEA terminologies

    The project

    Modules

    Folders

    Libraries

    Facets

    Artifacts

    Creating a project

    Creating a new project from scratch

    Importing the existing project

    Project format

    The directory-based format

    The file-based format

    The directory-based format versus the file-based format

    Summary

    3. The Editor

    An overview of the editor and setup

    The gutter area

    The Status bar

    Tabs

    Scratches

    Scrollbar

    Navigating in the editor

    Navigating between files

    Navigating within a single file

    The Search Everywhere feature

    The editor basics

    Searching for and replacing text

    Syntax-aware selection

    Column selection mode

    Clipboard history

    Reformatting the code

    Code completion

    Language injection

    Generating code

    Code inspection

    Using Live Templates

    Postfix code completion

    Comparing files and folders

    Comparing files

    Comparing folders

    Looking for help

    Viewing inline documentation

    Viewing type definitions

    Looking for usages

    Viewing method parameters

    Viewing the external documentation

    Summary

    4. Make It Better – Refactoring

    An overview of refactoring

    Refactoring actions

    Rename

    Find and Replace Code Duplicates

    Copy

    Move

    Move Instance Method

    Safe Delete

    Change Signature

    Type Migration

    Make Static

    Convert to Instance Method

    Extract refactorings

    Extract Variable

    Extract Constant

    Extract Field

    Extract Parameter

    Introduce Parameter Object

    Extract Method

    The Extract Method object

    Delegate

    Extract Interface

    Extract Superclass

    Inline

    Remove Middleman

    Wrap Return Value

    Invert Boolean

    Pull Members Up or Push Members Down

    Replace Inheritance With Delegation

    Convert Anonymous Class to Inner

    Encapsulate Fields

    Replace Constructor with Factory Method / Builder

    Generify

    Summary

    5. Make It Happen – Running Your Project

    A temporary configuration

    The permanent configuration

    The Run/Debug configuration for a Java application

    Creating a Tomcat server local configuration

    The Node.js configuration

    Configuration defaults

    Sharing the configuration

    Running

    Summary

    6. Building Your Project

    Editing Maven settings

    The Maven tool window

    Running Maven goals

    Using Gradle

    Executing Gradle tasks

    Summary

    7. Red or Green? Test Your Code

    Enabling the testing plugins

    Creating the test

    Creating a run/debug configuration for the test

    Running or debugging the test

    Keyboard shortcuts

    Summary

    8. Squash'em – The Debugger

    Debugger settings

    Setting up the JavaScript debugger

    Managing breakpoints

    Starting the debugger

    The Debug tool window

    Inspecting variables and evaluating expressions

    Debugger actions

    Keyboard shortcuts summary

    Summary

    9. Working with Your Team

    Enabling version control

    Checking out the project from the repository

    Configuring version control

    Working with version control

    Changelists

    Adding files to version control

    Committing files

    Getting changes from the repository

    Browsing the changes

    Reverting the local changes

    Using the difference viewer

    Displaying the history

    The log viewer

    Quickly executing VCS actions

    Keyboard shortcuts

    Summary

    10. Not Enough? Extend It

    Setting up the environment and project

    Developing the plugin functionality

    Deploying and publishing

    Summary

    Index

    IntelliJ IDEA Essentials


    IntelliJ IDEA Essentials

    Copyright © 2014 Packt Publishing

    All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

    Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.

    Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

    First published: December 2014

    Production reference: 1161214

    Published by Packt Publishing Ltd.

    Livery Place

    35 Livery Street

    Birmingham B3 2PB, UK.

    ISBN 978-1-78439-693-0

    www.packtpub.com

    Credits

    Author

    Jarosław Krochmalski

    Reviewers

    Scott Battaglia

    Andrew C. Dvorak

    Grzegorz Ligas

    Jan Thomä

    Commissioning Editor

    Dipika Gaonkar

    Acquisition Editors

    Ellen Bishop

    Sam Wood

    Content Development Editor

    Govindan K

    Technical Editor

    Aman Preet Singh

    Copy Editors

    Roshni Banerjee

    Adithi Shetty

    Project Coordinator

    Shipra Chawhan

    Proofreaders

    Simran Bhogal

    Stephen Copestake

    Maria Gould

    Ameesha Green

    Paul Hindle

    Indexer

    Monica Ajmera Mehta

    Production Coordinator

    Conidon Miranda

    Cover Work

    Conidon Miranda

    About the Author

    Jarosław Krochmalski is a passionate software designer and developer who specializes in the financial business domain. He has over 12 years of experience in software development. He is a clean-code and software craftsmanship enthusiast. He is a Certified ScrumMaster and a fan of Agile. His professional interests include new technologies in web application development, design patterns, enterprise architecture, and integration patterns. He likes to experiment with NoSQL and cloud computing.

    Jarosław has been working with IDEA since its first release and has observed the IDE grow and mature. He has been designing and developing software professionally since 2000 and has been using Java as his primary programming language since 2002. In the past, he worked for companies such as Kredyt Bank (KBC) and Bank BPS on many large-scale projects such as international money orders, express payments, and collection systems. He currently works as a consultant for the Danish company 7N and writes software for the Nykredit bank. You can reach him via Twitter at @jkroch or by e-mail at <[email protected]>.

    I would like to thank my wife, Marylka, and my two boys, Wojtuś and Mati, for being patient and letting me finish the book. Without their help and understanding, this book would not have been possible.

    I would like to thank all the people at Packt Publishing, especially Govindan K, Aman Preet Singh, Ellen Bishop, Richard Gall, and Sam Wood—you've made the entire writing and publishing process very smooth and straightforward. A special thanks to all the technical reviewers and proofreaders for providing me with valuable feedback from which I have learned a lot. Thank you.

    Greetings to my friends at 7N, Nykredit, Kredyt Bank, and Bank BPS—I hope you enjoy reading the book as much as I enjoyed writing it.

    About the Reviewers

    Scott Battaglia is a senior software development engineer for Audible Inc. (http://www.audible.com/), which is an Amazon.com, Inc. company and the leading provider of premium digital spoken audio information. He currently leads the shared Android platform team and coaches on a variety of topics, including open source, interviewing, and Scrum. Prior to this, he was an identity management architect and senior application developer with Rutgers, the State University of New Jersey.

    He actively contributed to various open source projects, including Apereo Central Authentication Service (CAS) and Inspektr, and has previously contributed to Spring Security, Apereo OpenRegistry, and Apereo uPortal. He has spoken at a variety of conferences, including Jasig, EDUCAUSE, and Spring Forward on topics such as CAS, identity management, Spring Security, and software development practices.

    Grzegorz Ligas is a software developer passionate about delivering solutions that are efficient and reliable. He started his career with a small company, writing software for the manufacturing industry, and then moved to retail banking. He currently works for an investment bank in London. Working in various sectors exposed him to technologies varying from mobile to highly distributed grid applications. He's the author of, and main contributor to, the IntelliJ XQuery Support plugin whose goal is to make XQuery development a pleasure.

    Jan Thomä is an IT consultant with over 15 years of experience in the IT industry. He has worked for various organizations and businesses, both small and large, including the City of Hamburg, Deutsche Telekom, and the Social Democratic Party of Germany. He has been using and endorsing IntelliJ IDEA ever since he discovered it in 2005 while searching for a truly productive and integrated development environment. He wrote and contributed to several plugins for the IntelliJ platform, including the OSGi and Leiningen plugins.

    www.PacktPub.com

    Support files, eBooks, discount offers, and more

    For support files and downloads related to your book, please visit www.PacktPub.com.

    Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and, as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at for more details.

    At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks.

    https://www2.packtpub.com/books/subscription/packtlib

    Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books.

    Why subscribe?

    Fully searchable across every book published by Packt

    Copy-and-paste, print, and bookmark content

    On-demand and accessible via a web browser

    Free access for Packt account holders

    If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access.

    Preface

    The first version of IntelliJ IDEA was released in January 2001. It is a mature, integrated development environment (IDE), designed to help you in the coding process, and supports a large number of different frameworks, tools, and targets. It works with multiple programming languages. It now includes full support for Java 8 and Java EE 7.

    The key objective of IntelliJ IDEA is to increase and assist developer productivity. Whether you develop in Java, Scala, or PHP, or make the frontend using HTML and JavaScript, IntelliJ IDEA's smart and relevant suggestions and code completion, on-the-fly code analysis, and respectable refactoring tools will support you in every step.

    When you are migrating from NetBeans or Eclipse, you will quickly see that IntelliJ IDEA is different because it understands the context. The IDE knows where you are in the editor and reacts accordingly; you will be surprised at how smart IntelliJ IDEA behaves.

    This tool is a generic workhorse rather than a strict Java IDE. In this book, you will learn how to make IntelliJ IDEA work for you and get your job done in the most efficient and pleasant way.

    What this books covers

    Although the book describes the latest version of IntelliJ IDEA - 14, most of the concepts will also work on the previous revision of the IDE.

    Chapter 1, Get to Know Your IDE, Fast, is a very concise note on editions comparison, requirements and installing IntelliJ IDEA in Windows, OSX, and Linux. This chapter guides you through the main workspace and show you ways to customize it for different tasks, presenting briefly the most useful plugins, IDE settings, and configuration tips.

    Chapter 2, Off We Go—To the Code, describes the process of setting up a new project or importing an existing one. The chapter explains terminology differences with NetBeans and Eclipse and presents the concept of modules and artifacts.

    Chapter 3, The Editor, describes the core of IntelliJ IDEA—the editor. In this chapter, you use state-of-the-art code completion, templates, and other great IntelliJ IDEA features. This chapter shows how to set up the editor and gives you some productivity tips.

    Chapter 4, Make It Better—Refactoring, presents the powerful refactoring toolset of IntelliJ IDEA. You are guided through the most useful refactoring techniques.

    Chapter 5, Make It Happen—Running Your Project, covers configuring the runtime environment for your project. We also talk about adding run configurations, either on the server or standalone. This chapter focusses not only on Java, but on other technologies such as Node.js as well.

    Chapter 6, Building Your Project, focusses on building a project. You use IntelliJ IDEA's own build system, and Maven and Gradle integration as well.

    Chapter 7, Red or Green? Test Your Code, is all about unit testing in IntelliJ IDEA. We focus on setting IntelliJ IDEA up specifically to run tests. You create JUnit and TestNG run configurations and then run and debug the tests. Then, you are given a brief overview of the test runner windows, useful settings, and option suggestions.

    Chapter 8, Squash'em – The Debugger, focusses on the IntelliJ IDEA debugger. You get familiar with the debugger tool window and debugger options. We look under the hood—evaluating expressions, using watches, conditional breakpoints, and other debugger features. We also talk briefly about remote debugging.

    Chapter 9, Working with Your Team, This chapter is all about version control, and managing change lists and tasks. There is a brief description on how to set up VCS integration, with the main focus on Git. This chapter describes integration with popular bug trackers, such as JIRA and YouTRACK.

    Chapter 10, Not Enough? Extend It, describes briefly the plugin architecture of IntelliJ IDEA. We talk about possibilities and develop a simple plugin, so that you have knowledge of how to extend the IDE. You are also presented with useful links and resources to develop your knowledge even further.

    What you need for this book

    You will need a Mac or PC, running OS X, MS Windows, or Linux, to be able to set up and run IntelliJ IDEA. To learn the presented features, you will also need the tool itself, of course. You can use the free 30-day trial of Ultimate Edition or use the Community Edition, which is available free of charge. We will flag the differences and let you know what features are not available in the free version of the IDE. You can read how to get it in Chapter 1, Get to Know Your IDE, Fast.

    Who this book is for

    This book is a fast-paced introduction to IntelliJ IDEA and is aimed at users who want to learn the essentials of the new IDE in a nimble and efficient way.

    Conventions

    In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

    Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: If you keep getting OutOfMemoryError in PermGen space exceptions, try to change the -XX:MaxPermSize setting.

    A block of code is set as follows:

    private boolean isValid(int a) {

      return a > 15 && a < 100;

    }

    Any command-line input or output is written as follows:

    git clone git://git.jetbrains.org/idea/community.git idea

    New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: To do this, first download the IntelliJ Configuration Server plugin, using the Plugins page of the Settings dialog box.

    Note

    Warnings or important notes appear in a box like this.

    Tip

    Tips and tricks appear like this.

    Reader feedback

    Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

    To send us general feedback, simply e-mail <[email protected]>, and mention the book's title in the subject of your message.

    If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

    Customer support

    Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

    Errata

    Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing

    Enjoying the preview?
    Page 1 of 1