Getting Started with Intellij Idea (10.5.1)

This document guides you through the process of writing and compiling a 'Hello World' type program using Intellij Idea.

First of all, find Intellij Idea on the desktop or start menu (look for IntelliJ IDEA under All Programs) and open the application - it may take a few seconds to start up. 

Select the File-New Project option, and you'll be presented a dialogue similar to the following. This will give you the choice to create a new project from scratch or from an existing source code/model. For this tutorial choose "create project from scratch". 

 

 

Next you need to choose a project name and the new folder you've just created. The same dialogue can be used to create different types of projects. For now select "Java Module" for a standard J2SE project.

 

 

Then click Next, to be presented with another dialogue, which will enable you to create a source folder (usually called src). You always have the option not to create such a folder but it is highly recommended to do so.
 

 

 

Next you will have the choice of including some advanced technologies into your project. Do not select any of the listed technologies as we are going to write a simple java project

 

 

 

Select finish and the project will load into the IDE.

Creating a Package

Select the Project view on the left Pane, and right click the 'test' module.  From the pop-up menu select 'new package' as shown below:

 

 

 

Now enter the name 'Test' for the package name:

 

 

And click Ok.

Now right click on "Test" to create a new class:

 

 

 

 

Enter the name 'HelloWorld'.

You should now see something like this in the code view:

 

 

 

The next step is to write the code.

Note that Intellij will format the code for you.  It does this as you type, but sometimes you'll need to manually invoke a 'reformat' - do this with <ctrl>+<alt>+L

To create the main method, you can use a built-in shortcut sequence: type psvm<tab> within the class definition, and you'll get this:

 

 

 

Now enter the single line at the cursor: System.out.println("Hello world!");  (you can do same of this with the shortcut sout<tab>).

Observe in the screen shot above the "yellow light" alongside the top right corner of the code window. This indicates that the code is ready to compile but there are some warnings, this light will turn into green when there are no warnings (can you figure out what is the warning).  Experiment with corrupting the code, and note the red light and the red line(s) that appear with appropriate error messages.

Make sure you've corrected any corruptions and then compile the code using the "Make Project" option from the Build menu or "Compile HelloWorld.java" option from the same menu, or the keyboard shortcut <ctrl><shift><F9>.

In order to run the program, right click on "Hello" class and select "run HelloWorld.main()".

 

Now, for next runs simply click the green triangle at the top of the window to run the program (if it isn't green the program is not runnable so check that you haven't missed any steps earlier!).

The output of the program should look something like the following:

 

 

 

Exercise

Study the directory structure of the project.  What do you notice about the location of each file that has been created?

Concluding Remarks

You may think right now that this was a fairly long-winded process to write a hello-world program, and that you could have done it quicker using TextPad!

That may be true for a Hello World program, but as the code you write becomes more complex, and exploits more of the Java API, a good IDE such as Intellij Idea is indispensible.

Learn to use it effectively and you will not regret it!

 

 

 

 

 

posted on 2011-07-18 16:42 NET未来之路 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/lonelyxmas/archive/2011/07/18/2109703.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Exploit IntelliJ IDEA’s unique features to rapidly develop web and Java Enterprise applications Overview Exhibit techniques that improve development performance Present framework support Create an application that explores the features of the integrated development environment (IDE) In Detail IntelliJ IDEA is a commercial Java development tool which competes with the free Eclipse and NetBeans projects. It is an integrated development environment (IDE) designed to automate parts of the coding process; to support a large number of different frameworks, tools, and targets; to work with multiple languages; and not to get in the way of the developer’s work. IntelliJ IDEA also does a good job of keeping up-to-date with the Java platform, subject to the expense of keeping current with the latest product version. A practical guide that will provide you with concepts and clear step-by-step exercises to help you understand and improve your performance. Through this guide, you will be able to extract more from IntelliJ IDEA 12. This book will navigate through the features of IntelliJ IDEA 12 and present the reader with concepts and tips that will give them a greater understanding of this IDE. Using a practical real-world example, readers will learn to develop one application and use some of the features presented. Through clear instructions, you will learn how to integrate the IDE with your favorite bug tracker, take a look at the refactoring approaches that IntelliJ offers, and will quickly understand and use different ways to navigate through the code. This book teaches you how to develop a web application and a simple Swing application. The development of this application will help you to understand how to work with IntelliJ's Swing GUI constructor. The book will also provide a simple code as starting point and will show you how to develop some code. What you will learn from this book Manage your tasks using (or not using) your favorite bug tracker Work with Spring framework with IntelliJ Understand and use the intentions and smart code completion features Create web services using the IntelliJ tools Install and use third party plugins Approach A practical, fast-paced guide with clear, step-by-step exercisesto help you understand the basics of IntelliJ Idea and develop a web application. Who this book is written for This book will be ideal if you are a Java developer who has a little knowledge about IntelliJ and wants to get more information on using it to improve your development performance. Product Details Paperback: 114 pages Publisher: Packt Publishing (October 17, 2013) Language: English ISBN-10: 1849699615 ISBN-13: 978-1849699617 Product Dimensions: 9.2 x 7.5 x 0.2 inches
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值