When creating a JAVA source file, make sure to append it with the .java extension.
Once you create a .java source file, you will compile it using the javac compiler.
If your source file contains errors, start with the first one.
When installing the J2SDK you must make sure your path is setup. The purpose of the path is to tell windows where to run executable files from. When you install the SDK tools you must check to make sure and add if necessary the appropriate information so windows knows where to find the java command line tools.
To set the PATH environment variable s value, right-click on the My Computer icon located on your desktop. This opens a pop-up menu. From the menu, click Properties to open the System Properties window. In the System Properties window, click the Advanced tab at the top right, then click the Environment Variables button located in the center of the tab window. This opens the Environment Variables window.
When you open the Environment Variables window, you will see two sections. The upper part of the window shows the user variables. User variables apply to your user login. The lower part of the window shows the system variables. System variables apply to all users, but they can be augmented by user variables. System variables can only be modified by users having Administrator privileges.
There will be a system PATH variable, but I recommend leaving the system variable alone and creating a user PATH variable. If your user PATH variable does not already exist, click the New button located below the user variables section. In the Variable Name field enter the name of the user variable:
PATH
In the Variable Value field add the fully-qualified path value to the SDK bin directory:
C:\j2sdk1.4.2_01\bin;
To this I would also add the path to the JRE bin directory. The complete PATH variable value will now resemble the following string:
C:\j2sdk1.4.2\bin;C:\j2sdk1.4.2_01\jre\bin;
Notice how the C:\j2sdk1.4.2_01 portion of the path must be repeated for both the SDK and the JRE portion of the PATH variable value. Also notice how each separate path entry is separated by a semicolon.
When you are finished creating or editing the PATH environment variable, be sure to click the OK button on each window to save your changes.
It s now time to test the PATH environment variable. Open a command-processor window as shown in figure 2-7 and enter the command javac . This should display the Java compiler help summary.
Now that you have set the PATH environment variable, the operating system can find the Java command-line tools. You must now tell the operating system where to find the Java Platform class files, as well as the class files you will create as part of your programming projects. You do this by setting the system CLASSPATH variable.
Setting The CLASSPATH Environment Variable
You set the CLASSPATH environment variable the same way you set the PATH environment variable. In fact, you can follow the same steps shown in figure 2-6. However, before setting the CLASSPATH, you will need to know two things: 1) where the Java Platform class files are located, and 2) where you are going to put your class files when you do your program development.
Let s start with the location of the Java Platform class-file location. To run Java programs, you will need the JRE. The JRE was installed along with the SDK, and is located in the jre subdirectory of the SDK. In the jre subdirectory you will find another subdirectory named lib which stands for library. The lib directory contains the Java Platform Application Programming Interface (API) files required to run Java programs. The fully-qualified path name that should be used for the CLASSPATH environment variable will be similar to this:
C:\j2sdk1.4.2_01\jre\lib
Now, to tell the java interpreter to look in the current directory for your project s class files (wherever you happen to be when you try running your Java programs) add the following path value:
.;
Yes, it s a period followed by a semicolon. The full CLASSPATH variable value will now look like this:
C:\j2sdk1.4.2_01\jre\lib;.;
While you re at it, you may as well add one more search location to the CLASSPATH. Do this by adding the following path value:
.\classes;
This will instruct the JVM to search for classes in a directory named classes , which is located in the working directory. The complete CLASSPATH variable value should now look like this:
C:\j2sdk1.4.2_01\jre\lib;.;.\classes;
When you have finished setting the CLASSPATH variable click the OK buttons to save your changes. You should now have both your PATH and CLASSPATH environment variables set. It s time to test everything by creating a few classes, compiling them, and running the resulting application class file.
Tuesday, October 2, 2007
Monday, October 1, 2007
Chapter 2 Small Victories, Creating Java Projects
Learning Objectives for Chapter 2.
List and describe the steps required to create and run a Java™ project
State the purpose and use of an Integrated Development Environment (IDE)
List and describe the components of a typical IDE
Describe the purpose and use of the following Java command-line tools: javac, java, javadoc, jar
List the steps required to create a Java project using Macintosh® OS® X developer tools
List the steps required to create a Java project using Sun's Java 2 Software Development Kit™ (SDK)
Explain in writing how to set the PATH and CLASSPATH environment variables
List the steps required to create a Java project using Borland’s JBuilder™ IDE
List and describe the steps required to create an executable jar file
This chapter is designed to get you up an running in a development environment and shows you how to create a project.
List and describe the steps required to create and run a Java™ project
State the purpose and use of an Integrated Development Environment (IDE)
List and describe the components of a typical IDE
Describe the purpose and use of the following Java command-line tools: javac, java, javadoc, jar
List the steps required to create a Java project using Macintosh® OS® X developer tools
List the steps required to create a Java project using Sun's Java 2 Software Development Kit™ (SDK)
Explain in writing how to set the PATH and CLASSPATH environment variables
List the steps required to create a Java project using Borland’s JBuilder™ IDE
List and describe the steps required to create an executable jar file
This chapter is designed to get you up an running in a development environment and shows you how to create a project.
Tuesday, September 11, 2007
Java For Artists Chapter 1 summary
Chapter 1: An approach to the art of programming
There are five steps to the programming cycle: plan, code, test, integrate, and refactor.
Use method stubbing to test sections of source code without having to code the entire method.
There are two types of complexity: conceptual and physical. Object-oriented programming and design techniques help manage conceptual complexity. Physical complexity is managed with smart project file-management techniques, by splitting projects into multiple files, and using packages to organize source code.
Self-commenting source code is easy to read and debug. Adopt smart variable, constant, and method-naming conventions and stick with them.
Maximize cohesion minimize coupling!
Chapter 1 Self test
1.
List at least seven skills you must master in your studies of the Java programming language.
The seven skills which must be mastered in order to be competent as a JAVA programmer are:
a. A development environment. You must have at least a text editor and a compiler to begin your work.
b. A computer
c. Problem Solving skills
d. Knowledge of how to approach programming tasks and projects.
e. How to put yourself in the mood to program
f. Object oriented programming and complexity
g. OO programming skills
h. An API
2. What three development roles will you play as a student?
Analyst -- At first you will play the role of analyst. You will need to work through the problem/task you are trying to accomplish and think of the many facets it may have.
Architect -- Once you understand your problem, you must design a solution for the problem. Two components of a good design are the scalability and a lack of complexity if possible.
Programmer -- You will then play programmer and actually code the project.
3. What is the purpose of the project-approach strategy?
The purpose of the project approach strategy is to give you directions and goals. It allows you to break large projects down into smaller units and accomplish small portions at a time.
4. List and describe the four areas of concern addressed in the project-approach strategy.
1. Application Requirements -- These requirements make assumptions about the application behavior.
2. Problem Domain -- This is the specific problem you are being asked to solve.
3. programming language features -- this is a listing of all features that will be used. review the list to make sure all components are understood.
4. High-Level Design & Implementation Strategy -- This can be a procedural based design approach or an object oriented design approach.
A procedural approach breaks the problem down into many smaller problems and keeps the code seperate from the data structures it manipulates.
An object oriented approach thinks about objects and the interactions between those objects. The data an object needs to maniupulate or work is contained within the object itself.
5. List and describe the five steps of the programming cycle.
6.
What are the two types of complexity?
There are 2 basic types of complexity. There is conceptual complexity which is that part of the software that is controlled by its architectural design. The better the architecture the better the design. If you plan well enough then scalability and changes are made easily.
The second type of complexity is physical complexity. Physical complexity is the number of designs and documents created by the programmers during the designing of the software.
7.
What is meant by the term isomorphic mapping ?
Isomorphic mapping refers to the idea that though 2 or more things can have differnt outwardly physical properties they are structurally the same and can be used intercahngebly. For example you have a brown deck of cards and a green deck. Even though the backs are different colors you could if you chose to divide them in two and play then mix them and still play cards.
8.
Why do you think it would be helpful to write self-commenting source code?
Self commenting code is an identifier naming technique that can be used to effectively manage both the physical and conceptual complexity. An identifier is a sequence of java characters or digits used to form names of entities used in your program. Examples of entities include classes, constants, variables and methods. All you have to do to write self commenting codes is to give meaningful names to your program entities and adopt a consistent naming convention. Because java allows unlimited identifier names you can be pretty desvriptive. The benefits of self commenting code are it is easier to read and therefore understand thereby making it easier to track down logic errors and mistakes.
There is a standard for self commenting code:
ClassNames should start with an initial capital letter and if there is more than one word in the class name capitalize each subsequent word used to fork the class name.
Examples: EngineController, ConditionReport, DataReferenceSync,
CONSTANT_NAMES Constants represent values in your code that cannot be changed once initialized. They should also describe the values they contain and should be all capitalized.
Examples: PI, MAX, MAX_MILES
variable_names Variable names represent values that can change while the program is running. Variable names should be formed from lowercase characters to set them apart from constants.
Examples: size, current_row, engine_size
methodNames A method represents a named series of JAVA statements that perform some action when called in a program. Since methods invoke actions their names should only be formed from action words(verbs) that describe what they do. Begin method names with a lower case character and capitalize each subsequent word of a multiple-word method.
Examples: printFloor, setMaxValue, getMaxValues
9.
What can you do in your source code to maximize cohesion?
Cohesion is the degree to which a piece of software sticks to its intended purpose. A high degree od module cohesion is desired. For example, a method intended to display an image on the screen would have a high degree of cohesion if that is all it did and poor cohesion if it did other things as well. So in order to maintain maximum cohesion, if you have other things to do put them in a different class or method.
10.
What can you do in your source code to minimize coupling?
Coupling is the degree to which one software module depends on software modules external to itself. A low degree of coupling is desired. Coupling can be controlled in object oriented software by depending upon interfaces or abstract classed rather than upon concrete implementation classes.
There are five steps to the programming cycle: plan, code, test, integrate, and refactor.
Use method stubbing to test sections of source code without having to code the entire method.
There are two types of complexity: conceptual and physical. Object-oriented programming and design techniques help manage conceptual complexity. Physical complexity is managed with smart project file-management techniques, by splitting projects into multiple files, and using packages to organize source code.
Self-commenting source code is easy to read and debug. Adopt smart variable, constant, and method-naming conventions and stick with them.
Maximize cohesion minimize coupling!
Chapter 1 Self test
1.
List at least seven skills you must master in your studies of the Java programming language.
The seven skills which must be mastered in order to be competent as a JAVA programmer are:
a. A development environment. You must have at least a text editor and a compiler to begin your work.
b. A computer
c. Problem Solving skills
d. Knowledge of how to approach programming tasks and projects.
e. How to put yourself in the mood to program
f. Object oriented programming and complexity
g. OO programming skills
h. An API
2. What three development roles will you play as a student?
Analyst -- At first you will play the role of analyst. You will need to work through the problem/task you are trying to accomplish and think of the many facets it may have.
Architect -- Once you understand your problem, you must design a solution for the problem. Two components of a good design are the scalability and a lack of complexity if possible.
Programmer -- You will then play programmer and actually code the project.
3. What is the purpose of the project-approach strategy?
The purpose of the project approach strategy is to give you directions and goals. It allows you to break large projects down into smaller units and accomplish small portions at a time.
4. List and describe the four areas of concern addressed in the project-approach strategy.
1. Application Requirements -- These requirements make assumptions about the application behavior.
2. Problem Domain -- This is the specific problem you are being asked to solve.
3. programming language features -- this is a listing of all features that will be used. review the list to make sure all components are understood.
4. High-Level Design & Implementation Strategy -- This can be a procedural based design approach or an object oriented design approach.
A procedural approach breaks the problem down into many smaller problems and keeps the code seperate from the data structures it manipulates.
An object oriented approach thinks about objects and the interactions between those objects. The data an object needs to maniupulate or work is contained within the object itself.
5. List and describe the five steps of the programming cycle.
6.
What are the two types of complexity?
There are 2 basic types of complexity. There is conceptual complexity which is that part of the software that is controlled by its architectural design. The better the architecture the better the design. If you plan well enough then scalability and changes are made easily.
The second type of complexity is physical complexity. Physical complexity is the number of designs and documents created by the programmers during the designing of the software.
7.
What is meant by the term isomorphic mapping ?
Isomorphic mapping refers to the idea that though 2 or more things can have differnt outwardly physical properties they are structurally the same and can be used intercahngebly. For example you have a brown deck of cards and a green deck. Even though the backs are different colors you could if you chose to divide them in two and play then mix them and still play cards.
8.
Why do you think it would be helpful to write self-commenting source code?
Self commenting code is an identifier naming technique that can be used to effectively manage both the physical and conceptual complexity. An identifier is a sequence of java characters or digits used to form names of entities used in your program. Examples of entities include classes, constants, variables and methods. All you have to do to write self commenting codes is to give meaningful names to your program entities and adopt a consistent naming convention. Because java allows unlimited identifier names you can be pretty desvriptive. The benefits of self commenting code are it is easier to read and therefore understand thereby making it easier to track down logic errors and mistakes.
There is a standard for self commenting code:
ClassNames should start with an initial capital letter and if there is more than one word in the class name capitalize each subsequent word used to fork the class name.
Examples: EngineController, ConditionReport, DataReferenceSync,
CONSTANT_NAMES Constants represent values in your code that cannot be changed once initialized. They should also describe the values they contain and should be all capitalized.
Examples: PI, MAX, MAX_MILES
variable_names Variable names represent values that can change while the program is running. Variable names should be formed from lowercase characters to set them apart from constants.
Examples: size, current_row, engine_size
methodNames A method represents a named series of JAVA statements that perform some action when called in a program. Since methods invoke actions their names should only be formed from action words(verbs) that describe what they do. Begin method names with a lower case character and capitalize each subsequent word of a multiple-word method.
Examples: printFloor, setMaxValue, getMaxValues
9.
What can you do in your source code to maximize cohesion?
Cohesion is the degree to which a piece of software sticks to its intended purpose. A high degree od module cohesion is desired. For example, a method intended to display an image on the screen would have a high degree of cohesion if that is all it did and poor cohesion if it did other things as well. So in order to maintain maximum cohesion, if you have other things to do put them in a different class or method.
10.
What can you do in your source code to minimize coupling?
Coupling is the degree to which one software module depends on software modules external to itself. A low degree of coupling is desired. Coupling can be controlled in object oriented software by depending upon interfaces or abstract classed rather than upon concrete implementation classes.
Purpose
The purpose of this journal is to be an online repository for notes while studying to achieve my goal of being a JAVA developer.
I will keep a summary of the material I learn each session and also will make note of interesting topics to follow up on.
I will keep a summary of the material I learn each session and also will make note of interesting topics to follow up on.
Subscribe to:
Posts (Atom)