Difference between revisions of "Compiling and the Java Virtual Machine"

From CompSciWiki
Jump to: navigation, search
(progress)
(progress)
Line 2: Line 2:
  
 
You do not need to understand everything that is covered in this section. The point of this section is to give you a basic understanding of how lines of code becomes a program that your computer can run, and why Java does this differently. |Chapter_TOC=[[Java Fundamentals]]}}
 
You do not need to understand everything that is covered in this section. The point of this section is to give you a basic understanding of how lines of code becomes a program that your computer can run, and why Java does this differently. |Chapter_TOC=[[Java Fundamentals]]}}
 +
 +
=Compiling=
  
 
What happens when you click on "Compile Java" in Textpad?  How do the lines of code that you write become a program that you can run on your computer?
 
What happens when you click on "Compile Java" in Textpad?  How do the lines of code that you write become a program that you can run on your computer?
  
=Compiling=
+
When you compile a program, a program called the '''compiler''' translates text written in one programming language into another programming language.  Java is a programming language that is (relatively) comprehensible by humans; it takes a while to learn, but once you learn the fundamentals of Java, you can read another Java program and understand the basics of what it is doing.  A computer, on the other hand, understands a different language that is not comprehensible by humans; each instruction is encoded as a sequence of 0's and 1's (e.g., 4+5 might be 1010 1000 1011 0100).  The language that a computer understands is called machine code, or machine language.  This is explained in greater detail in Chapter 2's [[What Is Programming Part II|Further reading]].
 +
 
 +
In general, a compiler takes lines of code and outputs the equivalent machine code that a computer can run.
 +
 
 +
// Todo: add compiler definition to the glossary
 +
 
 +
=The Java Compiler=
 +
 
 +
We use many different types of computers every day: we use a Windows computer
  
When you compile a program, a program called the '''Compiler''' translates text written in one programming language into another programming language.  Java is a programming language that is (relatively) comprehensible by humans; it takes a while to learn, but once you learn the fundamentals of Java, you can read another Java program and understand the basics of what it is doing.  A computer, on the other hand, uses a different language that is not really comprehensible by humans; each instruction is encoded as a short number (e.g., 3+4 might be 45 17).  The language that a computer understands is called machine code, or machine language.  This is explained in greater detail in Chapter 2's [[What Is Programming Part II|Further reading]].
+
[[Template:1010Topic2]]

Revision as of 11:45, 27 November 2007

COMP 1010 Home > Java Fundamentals


Introduction

Before you can run your Java program, you must compile it. Java is different than most programming languages because a program compiled on your computer will work on any other device that has a Java Virtual Machine, such as a cell phone.

   

{{{Body}}}

Compiling

What happens when you click on "Compile Java" in Textpad? How do the lines of code that you write become a program that you can run on your computer?

When you compile a program, a program called the compiler translates text written in one programming language into another programming language. Java is a programming language that is (relatively) comprehensible by humans; it takes a while to learn, but once you learn the fundamentals of Java, you can read another Java program and understand the basics of what it is doing. A computer, on the other hand, understands a different language that is not comprehensible by humans; each instruction is encoded as a sequence of 0's and 1's (e.g., 4+5 might be 1010 1000 1011 0100). The language that a computer understands is called machine code, or machine language. This is explained in greater detail in Chapter 2's Further reading.

In general, a compiler takes lines of code and outputs the equivalent machine code that a computer can run.

// Todo: add compiler definition to the glossary

The Java Compiler

We use many different types of computers every day: we use a Windows computer

Template:1010Topic2