Home arrow Java arrow Page 5 - Java Part 3: Primitive Types

Java Part 3: Primitive Types

In part two of this ten part series, I discussed some basic Java language syntax. In this article, I will discuss some of the Java primitive types and describe the basics of a Java class. I will also touch on the JDK (Java Development Kit) and describe how to compile a small class.

Author Info:
By: Chris Noack
Rating: 4 stars4 stars4 stars4 stars4 stars / 5
December 03, 2001
  1. · Java Part 3: Primitive Types
  2. · Primitive types in Java
  3. · Creating our first class
  4. · Our new class...explained
  5. · Compiling the Application
  6. · Conclusion

print this article

Java Part 3: Primitive Types - Compiling the Application
(Page 5 of 6 )

Before we can compile our example, we will need to install a working Java environment. We will use the JDK (Java Development Kit), which is a free download.

You can download the JDK for windows from http://java.sun.com/j2se/1.3/download-windows.html. The JDK is also available for Linux from http://java.sun.com/j2se/.

After installing the software, run through the documentation to make sure that you've set it up correctly. The JDK should now be ready to use. If you are encountering any problems, refer back to the documentation provided with the JDK.

To compile our example, we will need to save the example class that we have developed into a file named Number.java. When you create a class in a file, the filename has to match the name of the class. Save the file into a new directory, separate from your Java installation directory, c:\javacode, for example.

Java code is compiled, meaning that your source code file, Number.java is converted into byte-code. The Java Virtual Machine then executes the byte-code. To compile our class file, we use the javac program, as follows:

javac Number.java

This will compile your .java file into a .class file, which is now ready to run. To run your application, simply type the following line at the DOS prompt or Unix command line:

java Number

Do not type Java Number.class. You donít need to specify the .class extension! And there you have it, you have created your first Java application.
blog comments powered by Disqus

- Java Too Insecure, Says Microsoft Researcher
- Google Beats Oracle in Java Ruling
- Deploying Multiple Java Applets as One
- Deploying Java Applets
- Understanding Deployment Frameworks
- Database Programming in Java Using JDBC
- Extension Interfaces and SAX
- Entities, Handlers and SAX
- Advanced SAX
- Conversions and Java Print Streams
- Formatters and Java Print Streams
- Java Print Streams
- Wildcards, Arrays, and Generics in Java
- Wildcards and Generic Methods in Java
- Finishing the Project: Java Web Development ...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials