Easy to Learn Java: Programming Articles, Examples and Tips

Start with Java in a few days with Java Lessons or Lectures

Home

Code Examples

Java Tools

More Java Tools!

Java Forum

All Java Tips

Books

Submit News
Search the site here...
Search...
 
Search the JavaFAQ.nu
1000 Java Tips ebook

1000 Java Tips - Click here for the high resolution copy!1000 Java Tips - Click here for the high resolution copy!

Java Screensaver, take it here

Free "1000 Java Tips" eBook is here! It is huge collection of big and small Java programming articles and tips. Please take your copy here.

Take your copy of free "Java Technology Screensaver"!.

Easy Learn Java: Programming Articles, Examples and Tips - Page 511


Previous 1060 Stories (530 Pages, 2 Per Page) Next

How to get started with Java: The BlueJ IDE

Go to all tips in Murachs Java SE6 book

The BlueJ IDE

BlueJ is a free IDE that was developed as part of a university research project to teach object-oriented programming to first-year Java students. BlueJ is available for free, and you can download it from www.bluej.org. Although BlueJ doesn't provide as many features as IDEs like Eclipse and NetBeans, it provides some of the advantages of an IDE without some of the drawbacks. For example, BlueJ includes a debugger that's easy for students to learn. In addition, BlueJ maintains a diagram for each project that can help students visualize how the classes in a project work together. As a result, if you're new to objectoriented programming, you might want to try using BlueJ.

The NetBeans code editor



The NetBeans GUI builder

Figure 1-18 Two views of the NetBeans IDE

Introduction to Java ...................................................................... 4
Toolkits and platforms ....................................................................... 4
Java compared to C++ ...................................................................... 4
Java compared to C# ........................................................................ 4
Applications, applets, and servlets ....................................................... 6
How Java compiles and interprets code ................................................ 8
How to prepare your system for using Java .................................. 10
How to install the JDK ..........................................................................10
A summary of the directories and files of the JDK ...................................12
How to set the command path ...............................................................14
How to set the class path ..................................................................... 16
How to use TextPad to work with Java ........................................... 18
How to install TextPad ......................................................................... 18
How to use TextPad to save and edit source code ................................... 20
How to use TextPad to compile source code ........................................... 22
How to use TextPad to run an application ............................................... 22
Common error messages and solutions ................................................. 24
How to use the command prompt to work with Java ...................... 26
How to compile source code ................................................................. 26
How to run an application ..................................................................... 26
How to compile source code with a switch .............................................. 28
Essential DOS skills for working with Java ............................................. 30
How to use the documentation for the Java SE API ....................... 32
How to install the API documentation ..................................................... 32
How to navigate the API documentation ................................................. 34
Introduction to Java IDEs ................................................................ 36
The Eclipse IDE for Java ....................................................................... 36
The NetBeans IDE ................................................................................ 38
The BlueJ IDE ...................................................................................... 38
Perspective ....................................................................................... 40

The chapter 1 of Murach's Java SE 6 excellent book (it is a MUST for all newbees!) is published on our site with written permission of the copyright owner. It was slightly adapted to our site layout. If you want to take a look at PDF version please follow the link here.

6974 bytes more | comments? | Printer Friendly Page  Send to a Friend | Score: 0
Posted by jalex on Friday, August 17, 2007 (20:59:03) (4723 reads)

How to get started with Java: Perspective

Go to all tips in Murachs Java SE6 book

Perspective

In this chapter, you learned how to install and configure the JDK for developing Java programs. You learned how to use TextPad to enter, edit, compile, and run a program. You learned how to use the command prompt to compile and run programs. And you learned how to install and view the API documentation for the JDK. With that as background, you're ready to learn how to write your own Java applications.

Summary


  • You use the Java Development Kit (JDK) to develop Java applications. This used to be called the Software Development Kit (SDK) for Java. As of version 6, theStandard Edition (SE) of Java is called Java SE. In older versions, it was called the Java 2 Platform, Standard Edition (J2SE).
  • You can use Java SE to create applications and a special type of Internet-based application known as an applet. In addition, you can use the Enterprise Edition (EE) of Java, which is known as Java EE, to create server-side applications using servlets and JavaServer Pages (JSPs).
  • The Java compiler translates source code into a platform-independent format known as Java bytecodes. Then, the Java interpreter, or Java Runtime Environment (JRE), translates the bytecodes into instructions that can be run by a specific operating system. A Java interpreter is an implementation of a Java virtual machine (JVM).
  • When you use the JDK with Windows, you should add the bin directory (usually C:\Program Files\Java\jdk1.6.0\bin) to the command path and you should add the current directory to the classpath.
  • A text editor that's designed for working with Java provides features that make it easier to enter, edit, and save Java code.
  • Some text editors such as TextPad include commands for compiling and running Java applications. You can also use the command prompt to enter the commands for compiling and running an application.
  • When you compile a program, you may get compile-time errors. When you run a program, you may get runtime errors.
  • To compile code from the command prompt, you use the javac command to start the Java compiler. To run an application from the command prompt, you use thejava command to start the Java interpreter.
  • You can get detailed information about any class in the Java SE API by using a web browser to browse the HTML-based documentation for its Application Programming Interface (API).
  • An Integrated Development Environment (IDE) like Eclipse, NetBeans, or BlueJ can make working with Java easier.

Before you do the exercises for this chapter

Before you do any of the exercises in this book, you need to download the folders and files for this book from our web site (www.murach.com) and install them on your system. For complete instructions, please refer to appendix A. Then, you should follow the procedures shown in this chapter to install and configure the JDK (figure 1-4 through 1-7), TextPad (figure 1-Cool or an equivalent text editor, and the documentation for the Java API (figure 1-15).

Exercise 1-1 Use TextPad to develop an application

This exercise will guide you through the process of using TextPad to enter, save, compile, and run a simple application.

Enter and save the source code

1. Start TextPad by clicking on the Start button and selecting Programs or All Programs TextPad.

2. Enter this code (type carefully and use the same capitalization):

public class TestApp
{
    public static void main(String[] args)
         {
              System.out.println(
                      "This Java application has run successfully");
          }
}

3. Use the Save command in the File menu to display the Save As dialog box. Next, navigate to the c:\java1.6\ch01 directory and enter TestApp in the File name box. If necessary, select the Java option from the Save as Type combo box. Then, click on the Save button to save the file.

Compile the source code and run the application

4. Press Ctrl+1 to compile the source code. If you get an error message, read the error message, edit the text file, save your changes, and compile the application again. Repeat this process until you get a clean compile (the code is displayed with no error messages).

5. Press Ctrl+2 to run the application. This application should display a console window that says "This Java application has run successfully" followed by a line that reads "Press any key to continue...".

6. Press any key. This should close the console window. If it doesn't, click on the Close button in the upper right corner of the window to close it.

Introduce and correct a compile-time error

7. In the TextPad window, delete the semicolon at the end of the System.out.println statement. Then, press Ctrl+1 to compile the source code. TextPad should display an error message that indicates that the semicolon is missing in the Command Results window.

8. In the Document Selector pane, click on the TestApp.java file to switch back to the source code, and press Ctrl+F6 twice to toggle back and forth between the Command Result window and the source code. Then, select View Line Numbers to display the line numbers for the source code lines.

9. Correct the error and compile the file again (this automatically saves your changes). This time the file should compile cleanly, so you can run it again and make sure that it works correctly.

10. Select Configure Preferences, click on View, and check Line Numbers. That will add line numbers to the source statements in all your applications. If you want to look through the other options and set any of them, do that now. When you're done, close the file and exit TextPad.

Exercise 1-2Use any Java development tool todevelop an application

If you aren't going to use TextPad to develop your Java programs, you can try whatever tools you are going to use with this generic exercise.

Use any text editor to enter and save the source code

1. Start the text editor or IDE and enter this code (type carefully and use the same capitalization):
public class TestApp
{
     public static void main(String[] args)
          {
              System.out.println(
                     "This Java application has run successfully");
           }
}

2. Save this code in a file named "TestApp.java".

Compile the source code and run the application

3. Compile the source code. If you're using a text editor or IDE that has a compile command, use this command. (Note that some IDEs automatically compile the source code when you run the application). Otherwise, use your command prompt to compile the source code. To do that, start your command prompt and use the cd command to change to the directory that contains the source code.

Then, enter the javac command like this (make sure to use the same capitalization):

javac TestApp.java

4. Run the application. If you're using a text editor or IDE that has a run or execute command, use this command. Otherwise, use your command prompt to run the application. To do that, enter the java command like this (make sure to use the same capitalization):

java TestApp

5. When you enter this command, the application should print "This Java application has run successfully" to the console window.

Exercise 1-3

Use the command prompt to run anycompiled application

This exercise shows how to use the command prompt to run any Java application.

1. Open the command prompt window. Then, change the current directory to

c:\java1.6\ch01.

2. Use the java command to run the LoanCalculatorApp application. This application calculates the monthly payment for a loan amount at the interest rate and number of years that you specify. This shows how the JRE can run any application whether or not it has been compiled on that machine. When you're done, close the application to return to the command prompt.

Exercise 1-4 Navigate the API documentation

This exercise will give you some practice using the API documentation to look up information about a class.

1. Start a web browser and navigate to the index page that contains the API documentation for the JDK (usually C:\Program Files\Java\jdk1.6.0\docs\ api\index.htm). This page should look like the one shown in figure 1-16.

2. Bookmark this page so you can easily access it later. To do that with the Internet Explorer, select the Add To Favorites item from the Favorites menu. Then, close your web browser.

3. Start your web browser again and use the bookmark to return to the API documentation for the JDK. To do that with the Internet Explorer, select the Java Platform SE item from the Favorites menu.

4. Select the java.lang package in the upper left frame and notice that the links in the lower left frame change. Select the System class from this frame to display information about it in the right frame.

5. Scroll down to the Field Summary area in the right frame and click on the out link for the standard output stream. When you do, an HTML page that gives some information about how to use the standard output stream will be displayed. In the next chapter, you'll learn more about using the out field of the System class to print data to the console.

6. Continue experimenting with the documentation until you're comfortable with how it works. Then, close the browser.


Introduction to Java ...................................................................... 4
Toolkits and platforms ....................................................................... 4
Java compared to C++ ...................................................................... 4
Java compared to C# ........................................................................ 4
Applications, applets, and servlets ....................................................... 6
How Java compiles and interprets code ................................................ 8
How to prepare your system for using Java .................................. 10
How to install the JDK ..........................................................................10
A summary of the directories and files of the JDK ...................................12
How to set the command path ...............................................................14
How to set the class path ..................................................................... 16
How to use TextPad to work with Java ........................................... 18
How to install TextPad ......................................................................... 18
How to use TextPad to save and edit source code ................................... 20
How to use TextPad to compile source code ........................................... 22
How to use TextPad to run an application ............................................... 22
Common error messages and solutions ................................................. 24
How to use the command prompt to work with Java ...................... 26
How to compile source code ................................................................. 26
How to run an application ..................................................................... 26
How to compile source code with a switch .............................................. 28
Essential DOS skills for working with Java ............................................. 30
How to use the documentation for the Java SE API ....................... 32
How to install the API documentation ..................................................... 32
How to navigate the API documentation ................................................. 34
Introduction to Java IDEs ................................................................ 36
The Eclipse IDE for Java ....................................................................... 36
The NetBeans IDE ................................................................................ 38
The BlueJ IDE ...................................................................................... 38
Perspective ....................................................................................... 40

The chapter 1 of Murach's Java SE 6 excellent book (it is a MUST for all newbees!) is published on our site with written permission of the copyright owner. It was slightly adapted to our site layout. If you want to take a look at PDF version please follow the link here.

17691 bytes more | comments? | Printer Friendly Page  Send to a Friend | Score: 0
Posted by jalex on Friday, August 17, 2007 (20:55:10) (2850 reads)

Previous 1060 Stories (530 Pages, 2 Per Page) Next

530| 529| 528| 527| 526| 525| 524| 523| 522| 521| 520| 519| 518| 517| 516| 515| 514| 513| 512|
511
| 510| 509| 508| 507| 506| 505| 504| 503| 502| 501| 500| 499| 498| 497| 496| 495| 494| 493| 492| 491| 490| 489| 488| 487| 486| 485| 484| 483| 482| 481| 480| 479| 478| 477| 476| 475| 474| 473| 472| 471| 470| 469| 468| 467| 466| 465| 464| 463| 462| 461| 460| 459| 458| 457| 456| 455| 454| 453| 452| 451| 450| 449| 448| 447| 446| 445| 444| 443| 442| 441| 440| 439| 438| 437| 436| 435| 434| 433| 432| 431| 430| 429| 428| 427| 426| 425| 424| 423| 422| 421| 420| 419| 418| 417| 416| 415| 414| 413| 412| 411| 410| 409| 408| 407| 406| 405| 404| 403| 402| 401| 400| 399| 398| 397| 396| 395| 394| 393| 392| 391| 390| 389| 388| 387| 386| 385| 384| 383| 382| 381| 380| 379| 378| 377| 376| 375| 374| 373| 372| 371| 370| 369| 368| 367| 366| 365| 364| 363| 362| 361| 360| 359| 358| 357| 356| 355| 354| 353| 352| 351| 350| 349| 348| 347| 346| 345| 344| 343| 342| 341| 340| 339| 338| 337| 336| 335| 334| 333| 332| 331| 330| 329| 328| 327| 326| 325| 324| 323| 322| 321| 320| 319| 318| 317| 316| 315| 314| 313| 312| 311| 310| 309| 308| 307| 306| 305| 304| 303| 302| 301| 300| 299| 298| 297| 296| 295| 294| 293| 292| 291| 290| 289| 288| 287| 286| 285| 284| 283| 282| 281| 280| 279| 278| 277| 276| 275| 274| 273| 272| 271| 270| 269| 268| 267| 266| 265| 264| 263| 262| 261| 260| 259| 258| 257| 256| 255| 254| 253| 252| 251| 250| 249| 248| 247| 246| 245| 244| 243| 242| 241| 240| 239| 238| 237| 236| 235| 234| 233| 232| 231| 230| 229| 228| 227| 226| 225| 224| 223| 222| 221| 220| 219| 218| 217| 216| 215| 214| 213| 212| 211| 210| 209| 208| 207| 206| 205| 204| 203| 202| 201| 200| 199| 198| 197| 196| 195| 194| 193| 192| 191| 190| 189| 188| 187| 186| 185| 184| 183| 182| 181| 180| 179| 178| 177| 176| 175| 174| 173| 172| 171| 170| 169| 168| 167| 166| 165| 164| 163| 162| 161| 160| 159| 158| 157| 156| 155| 154| 153| 152| 151| 150| 149| 148| 147| 146| 145| 144| 143| 142| 141| 140| 139| 138| 137| 136| 135| 134| 133| 132| 131| 130| 129| 128| 127| 126| 125| 124| 123| 122| 121| 120| 119| 118| 117| 116| 115| 114| 113| 112| 111| 110| 109| 108| 107| 106| 105| 104| 103| 102| 101| 100| 99| 98| 97| 96| 95| 94| 93| 92| 91| 90| 89| 88| 87| 86| 85| 84| 83| 82| 81| 80| 79| 78| 77| 76| 75| 74| 73| 72| 71| 70| 69| 68| 67| 66| 65| 64| 63| 62| 61| 60| 59| 58| 57| 56| 55| 54| 53| 52| 51| 50| 49| 48| 47| 46| 45| 44| 43| 42| 41| 40| 39| 38| 37| 36| 35| 34| 33| 32| 31| 30| 29| 28| 27| 26| 25| 24| 23| 22| 21| 20| 19| 18| 17| 16| 15| 14| 13| 12| 11| 10| 9| 8| 7| 6| 5| 4| 3| 2| 1|


Home Code Examples Java Forum All Java Tips Books Submit News, Code... Search... Offshore Software Tech Doodling

RSS feed Java FAQ RSS feed Java FAQ News     

    RSS feed Java Forums RSS feed Java Forums

All logos and trademarks in this site are property of their respective owner. The comments are property of their posters, all the rest 1999-2006 by Java FAQs Daily Tips.

Interactive software released under GNU GPL, Code Credits, Privacy Policy