Showing posts with label Java. Show all posts
Showing posts with label Java. Show all posts

Monday, June 24, 2013

Learning JavaSricpt Language

A. Introduction

When computers have become widespread in schools and homes and their uses in language teaching and learning have expanded dramatically from simple games to global networking, language teachers must now begin to think about the implication of computers for language teaching and learning.

The Internet, and its more recent offspring WWW (World Wide Web), is constantly growing in popularity and availability for all people. This allows commercial and educational organizations shift their materials delivery over the Internet. Many English teachers put their materials online. They create homepages just for the purpose of their classes, or they may design homepages so that every people can learn from them or take the pages for their own purposes.

Once we have access and surfing the Internet, we will find unlimited sources/links. One page is linked to one and the others so that it forms chain of resources. The resources range from individual home pages to institutional home pages like a university Home Page. In this article I try to sort out the ESL Internet resources and classify them into three broad categories. These categories are based on the computer’s roles framework. Tylor’s taxonomies of computer’s role are used here.
This writing is divided into two main parts. The first part (Background) will discuss three main issues. Firstly, the conflict of whether to use or not the computer in language learning is briefly reviewed. This issue should be highlighted since many educators still feel doubtful to bring this technology into classroom. They say that computers cause more frustrating than good. The discussion will cope with the conflict.

The next issue is the computer roles in education. This focuses on Levy’s discussion of tutor-tool-tutee framework. This framework is then chosen to be the feature for classification of the Internet resources made in this paper. Finally, at the end of the first part, I will discuss the ESL/EFL activities on the Internet in brief.
In the second part of this writing, I will take some home pages as examples and classify them according to the tutor-tool-tutee framework. The annotation will be attached to each homepage as brief descriptions.

B. Background


1. The conflict

New technology is often perceived as a promise. Computers, for example, can be tremendously useful for English language learning and teaching. They can process user input quickly, and integrate texts, pictures, sounds, and videos into a package of lessons. They can be programmed to diversify instructions so that it brings in students to learn more. In other words, there is a motivational value of using computers in language learning (Warschauer, 1996a). Therefore, many people argue that computers should be used for language learning. They believe that there are many potential benefits of using computers. However, the issue is not whether they are beneficial or not but rather how they should be used in language learning. Regardless of that whether computers have advantages and disadvantages in educational world in broad sense and in language learning and teaching in particular, for whatever reasons they are already being used and will continue to be used.

Computers are now seen as a hero in educational difficulties like inadequate funding, insufficient teaching stuffs, uninteresting materials, and so on. Some think that computer will eventually replace teachers (Hoffman, 1995/1996). However, it is unlikely that computers will ever meet the most excessive expectations. For example, Frizler (1995) states that it is an imaginary that computers will ever replace teachers. Snyder (1994) also believes that computers can not and should not replace teachers, but should be used by teachers to enhance their instructions. Patrikis (1997), even though slightly incompatibly to previous arguments, remarks that ‘computers are hardly ever to replace teachers, but they are equally unlikely to make poor teachers gifted teachers.’

For whatever reasons stated above, there are some that refute those arguments. Computers are said to be actually worse that useless. For instance, they may cause to reduce creativity of thought, and take precious funding away from other more worthy educational programs (Oppenheimers, 1997). Similarly, Patrikis (1997) argues that technology advances more rapidly than language methodology and pedagogy. As a result, the language learning pedagogy used in the technology is not working harmoniously or is outdated. Furthermore, Murison-Bowie (1993) argues that computers are not being utilized by teachers to their potential. Teachers do not seem to be taking advantages of technology’s possible benefits. He claims that several parties were responsible for this problem—teachers for not being easily-adapted, material developers for not understanding new technologies could be used to meet the profession’s needs, hardware developers for creating restrictive systems which dictate the teaching methods.

Computer-Assisted Language Learning (CALL) has not always been designed and used with the best or most current pedagogical foundation as Patrikis said before. Nancy Hunt (1993) discusses the problem of educators having a narrow view of the use of computer technology, mainly for independent drills and word processing. When in fact newer technologies to be used to help the students actively participate in language learning. Conrad (1996) noted that CALL software in 1980’s seemed to be outdated pedagogical approaches. Not until recently has CALL begun to conform the newer pedagogical approaches.

Finally, a common problem is for the excitement surrounding a new technology to cause teachers to forget to use good pedagogy. For instance, the attractiveness of the Internet or Web causes many teachers to fall into trap of thinking that just having their students online doing language exercises (Frizler, 1995). Therefore, there is a need for considering carefully the use of computer technology. It should be well-received and useful rather than a source of public disappointment. The technology should be used to the maximum level of its capability to enhance language learning, and pedagogical research and practices should lead to what is done with the technology, not the other way round.

In short, I should say that it is outdated to argue whether or not to use computers in education (language learning in particular). Computers are already being used anywhere. They are parts of our daily life. The issue now is not that conflict. However, 'the fundamental issue in the field of CALL is the “fit” between the computer’s capabilities and the demand of language pedagogy' (Wyatt, 1988). It is our duty as language teachers or CALLers to find ways how to maximize the use of computers in our ‘business’, to find the most appropriate pedagogical foundation for their uses.

The end of this conflict (whether or not to use computer technology in language learning) should bring us to another issue of CALL. This issue is about the roles of computer in language learning and teaching.

2. Tutor-Tool-Tutee Framework

I understand why there are still some educators who doubt to use computers in their classrooms. It is because of the essence of computers as machines. Computers are not human beings. They can not think and can neither feel. They just respond as they are programmed. In contrast, a good human teacher has two capacities (Higgins: 1984) which a computer or any machine does not have. One is feeling. A good teacher loves her students. She treats her students humanely. The second capacity is sensitivity. A good teacher can read her students’ feeling. She might know what is wrong with the students. If a mistake occurs, she will know whether it is because of deliberateness, carelessness, or genuine misunderstanding of a concept. On the other hand, computers hardly ever have those capacities.

From this illustration, a question arises: are computers useless in the classroom? The answer is of course ‘no.’ The advantage of using computers varies to some extend depending on how the computers are programmed. This will lead us to the discussion of the roles of computer in language learning and teaching, what computers can and cannot do.

Levy (1997) discusses this issue in great detail but I should start from Higgins’ taxonomies of computer roles. Higgins (1985) discusses two roles of computer, magister and pedagogue (this issue is also discussed in Levy, 1997). In magister role, computers are superior to the human (teachers and students) since they take the control—presenting, questioning, drilling, and evaluating. The other role is pedagogue. Higgins illustrates the pedagogue role as a slave because the computers are passive. They wait for the instructions from the users. They can be ‘a task setter, an opponent in a game, an invironment, a conversational partners, a stooge, or a tool’ (Higgins in Levy, 1997). Higgins (1984) says that computers are bad at magister and good at pedagogue.

Unlike Higgins, Wyatt’s taxonomies of computer roles are more than just two. Wyatt (1984) introduces one more which is called collaborative role beside instructor and facilitator which are relevant to Higgins’ magister and pedagogue respectively. In collaborative role, students and computers cooperate in a certain task. In this case, the student initiate and control the activities that may happen in the computer (Wyatt, 1984). Collaborative software casts students in a much more active role and depemds on them to taqke responsibility for their own learning.

These frameworks (Higgins’ and Wyatt’s) are in line with Tylor’s taxonomies, tutor, tool, and tutee (Levy, 1997). Levy summerises the tutor, tool, and tutee roles of computers as follows.

As a tutor a computer evaluates the learners and then provide next activities accordingly. A computer as a tutor implies that a computer can replace the presence of the teachers and that the activities can happen in self-access mode. Levy says that the nature of ‘computer tutor is the notion of the teacher in the machine rather than the teacher working with the students alongside the machine’. In other words, the computer serves as a vehicle for delivering instructions to the students. Computers as tutor are useful in some cases. Th fact says that CALL drills are still used today (Warschauer, 1996b). According to Warschauer, the rationale behind the computers as tutor is as follows:
  1. Repeated exposure to the same material is beneficial or even essential to learning
  2. A computer is ideal for carrying out repeated drills, since the machine does not get bored with presenting the same material and since it can provide immediate non-judgmental feedback
  3. A computer can present such material on an individualized basis, allowing students to proceed at their own pace and freeing up class time for other activities (Warschauer, 1996b)
Unlike the tutor role, the tool role of computers is to improve the efficiency of work of teachers and students (Levy, 1997). Warschauer (1996b) called this role as ‘computer as workhorse’. In this role, the computers do not necessarily provide learning materials at all, but rather empower the student to understand the lessons (Warschauer, 1996b). Computers as tool include word processing, spelling and grammar checking, desktop publishing program, and concordances.

The role of computers as tutee allows students or teachers to interfere the program. The students do not only simply absorb the materials from the computer (tutor) or respond the computers (tool) but also they should have some kind of interaction between students and computers where the students take more control. In this role computers provide manipulable space or field for creating models or conceptual structures (Levy, 1997). In other words, computers are used as tool to discover the information the computers possess where the students are responsible for initiating and directing the activities that occur in the learning environment.

Two things are clear here. In computer tool framework, computers are used as tool to reinforce the learning such as be a partner in conversation, an opponent in a game, or a challenger in a puzzle. Here student cannot interfere the program at all. On the other hand, in computer tutee framework, computers are used as tool to explore learning environment. For that reason, students take more control or direct the computers to achieve the goal.

3. Language learning on the Internet.

Let us move on to discuss the greater sophistication of computer use in language learning; it is the Internet.
Uschi Felix defines the Internet as “the world’s largest computer networking linking millions of individual computers at different sites raging from commercial business to educational institutions … connected to each other by land cables and other linkages.” One of the outstanding features of the Internet, particularly its more recent offspring World Wide Web (WWW), is that it is multi media. We can put texts, graphic images, audio, video in a single page of HTML (Plass and Chun, 1996). HTML stands for hypertext mark-up language; we use this language to build up a homepage. More technical explanation of the Internet in detail can be read in Uschi Felix’ book ‘Virtual language learning’ part 3, or at http://www.tcom.ohiou.edu/OU_Language/help/index.html the online Internet course by Ohio University.

Once we have begun to collect sites, create our own home pages, we are ready for the next step, putting course materials on-line and making them interactive. There are many different kinds of interactivity possible on the Web today, but what I have in mind are pages which allow (or require) user input (typing, clicking) with appropriate responses to that input or pages which enable users to work collaboratively.

I think we all recognize that our discipline requires a more active kind of learning than most. We cannot learn to use a language by listening to lectures or by just studying the theory (or the grammar). As in learning to play the piano, practice is essential. Therefore, it stands to reason if we are going to consider the Web as teacher's aid, we need to empower that aid to interact with the students, not just to lecture them (computer as tutor). To the extent that it is possible, we want students to work with authentic language materials, and to verify their comprehension through some kind of testing and feedback. We want to have students use the language as much as possible, including outside of class, through writing and speaking. We want students to interact with one another, to use the language for real communication (not just in staged classroom scenarios), to learn from one another. In short, we expect that the learning take place in such environment somehow. All this is doable on the Web, to one degree or another.

There are several styles of user/system interaction possible in standard Web configurations. One of the first uses of the Internet and other digital technologies has been computer-mediated communications. These can be divided into two broad categories: Synchronous and Asynchronous. With "asynchronous applications", messages are either E-Mailed or posted on a system where, upon login, users are notified of the new postings they have not yet accessed. Example systems have traditionally been computer conferencing and computer bulletin boards. In Synchronous Applications users are online at the same time, exchanging messages and other information in real time as they communicate. Examples of this category are Internet Relay Chat (IRC) and Multiple User Domain (MUD) (Sanchez, 1996). This class of interaction system is used for social role playing and is being supplemented as well by the newer MOO for "MUD, Object-Oriented", MUSH "Multi-user Shared Hallucination". Access Steve Thorne's Web page on these technologies for more information. Also see John December's resource list on computer-mediated communication for additional information on these topics in their more generic, non-language learning specific settings. Visit the Web entrance to see how a site functions that is not based on static Web pages.

The final category of interactions is one that is garnering the most attention today with respect to developments surrounding the Web. Going beyond HTML markup commands in a static Web page, this approach does more than increase interactivity on the server side through the use of CGI scripts that tailor what users see. This approach also avoids some of the negative elements of pre-placing assets on the user's local system for quicker access than is possible on the Net. Fitting into this category are developments such as the Java Programming (Reeser, 1997).

Let us keep in mind, however, that we are talking about an electronic means to enhance classroom instruction, to provide students with opportunities to use the language outside of class. Computers and the Web can never provide as effective or efficient a means of learning a language as one-on-one human interaction. With all the type of technological changes, teachers should not fear for their profession or for their job--computers can never replace human beings as has been discussed before.

However, technology is causing and accelerating major social and educational change. Sooner or later, all teachers will be expected to take advantage of some aspects of technology in their teaching. If they do not follow the move, they will be outdated or even will be left behind by their students. Nonetheless, once teachers begin creating dynamic Web pages, they will find they are working in a richly enabling environment, one which allows them not just to follow in the path others have taken, but to invent new paradigms. Fundamentally, we want to use technology to supplement what we do in the classroom and to help in doing what we cannot do very well now (share multimedia, collaborate long distance, make authentic materials comprehensible, etc). But we also want to use the technology to help us think "out of the box", to experiment with approaches we had never thought of before.

On the most basic level, I am talking about beginning with what are essentially Web pages. The Web offers the possibility of making our materials available electronically and putting them into an interactive environment. There are several advantages to doing this on the Web:
  1. Materials can be updated easily.
  2. Students have 24-hour, remote, independent access
  3. The pages can support customized help, review or extra-credit projects to accommodate students at different levels of preparation and ability, including students with special needs.
Let us back to the main purpose of this writing i.e. trying to classify web-based materials according to tutor-tool-tutee framework.

According to Harris as cited in Hackbarth (1997) there are three general type of online materials. The first type is interpersonal exchange. Interpersonal include exercises such as electronic mentoring, email exchanges. I consider this type as computer tool activities because there is two-way communication between a computer and student and communication among students through computers (the Internet). The second type is information collection. I consider this as computer tutor framework because a computer is used to deliver instructional materials. The last category made by Harris is problem-solving project. I categorize this type as computer tutee framework. Although Harris explanation about problem-solving project is not directly related to computer tutee framework, but it implies that students use a computer and take more control. Here students as users put their data and there is collaboration between users and the computers, somehow.

In conclusion, the Internet promotes philosophies of shared resources and knowledge plus active involvement in learning process. Indeed, this rich resource lends itself naturally to being an effective teaching and learning tool for student-centered, communicative and collaborative classroom.

C. Annotated Samples Of Web Sites.


The following sites are examples that represent to the classification that I discussed above. the annotations below the sites are to describe briefly what the examples are about. It is difficult to find a single web site that represents exactly to the frameworks outlined in this writing. One web may represent two or even three frameworks al together (tutor, tool, and tutee). Therefore, the examples listed below are classified according to their dominance. If a tutor-role framework is dominant in a certain site, so then it is classified into the example of tutor-role of computer, and so forth

The number of examples provided here does not show the ratio of the number of web sites available online at hte present time.

1. The tutor role of computer

a. English as Second language URL http://www.lang.uiuc.edu/r-li5/esl/index.htm


English as a Second Language is a starting point for ESL learners who want to learn English through the World Wide Web. This home page links to other ESL sites and other interesting places. The variety of materials will allow students to choose something appropriate for them. Basically this site contains information and links to other ESL sites; however, there are some exercises that allow students to interact with the computers like puzzles. This site also contains large audio files. Copyright © 1994, 1996, 1998 Rong-Chang Li

b. ESLoop URL http://www.tesol.net/esloop/esloop.html

ESLoop is a collection of sites relevant to English Language Teaching and Learning on the World-Wide Web. The ESLoop is run by a cgi-driven system, kindly donated by Sage Weil of the Webring. ESLoop was begun in 1996 as a way to offer teachers and students of English a way to browse the internet for resources specific to English language teaching and learning
ESLoop sites are all relevant to English language teaching and learning in some manner, from student projects and activities to scholarly papers to English for Science and Technology and job opportunities

c. Online English URL http://www.geocities.com/Athens/Olympus/9260/online.html

Online English is an English course organised by Paolo Rossetti from YMCA International College, Vancouver Canada. It is mainly conducted via email between the students and the teacher as the webmaster. The students will receive lessons via email regularly once a week. There will be 52 lessons a year. The lessons will have exercises on useful vocabulary, grammar, reading and listening comprehension and students can access a Conferencing Center for discussions with other members. All materials can be accessed from the Internet. Every lesson will be different and be based on real English used on the Internet.

d. Native American Lore Index Page URL http://www.ilhawaii.net/~stony/loreindx.html

This site is mainly to provide Reading exercises for ESL students. It consists of several stories of Native American Indian Lore from several Tribes across Turtle Island. The students may send their own stories to the web site owner and put them online. There are over 100 stories available here. While we read the stories, we can listen to background music. Copy right 1996.

e. Advanced Composition for Non-Native Speakers of English URL http://www.homestead.com/esl_efl/index.html

This website is for ESL/EFL students who want to learn to write well in English for academic purposes. There are a lot of documents within these pages; however, their organization is simple. First, there are a series of articles that explain how to write effective essays. Second, there are links to stories by professionals. Finally, there are many students' essays, interesting from a multicultural perspective.

For ESL/EFL teachers, this website contains "Advanced Composition" course content. This site also contains a rationale for the use of portfolio development within composition classes.

2. The tool role of computer


a. Poetry URL http://prominence.com/java/poetry/

The Magnetic Poetry Kit by Dave Kapell can be useful for anyone who is interested in writing poems. Students/teachers can simply rearrange some of the 300 words shown on the screen. There are suffixes, prefixes and an extensive word list. They can play online by clicking and dragging or they can print out the list of words to compose their own poem off-line. Copyright © 1998 Prominence Dot Com, Inc

b. EXCHANGE URL http://deil.lang.uiuc.edu/exchange/

EXCHANGE stands for Electronic, Xross Cultural, Hypertextual Academy of Non-native Gatherings in English. The goals of EXCHANGE are to provide an opportunity for non-native English speakers to express themselves through the use of English, to provide resources to enhance English learning, and to create a unique source of knowledge and insight about different cultures. To accomplish these goals, EXCHANGE publishes writings of non-native English speakers from all over the world, and provides English self-study materials. Two of activities of EXCHANGE are Creative writing by individual and collaborative writers. And key-pals to find friends all over the world, to share experiences while learning English. Last updated Friday, April 30, 1999

c. Interactive JavaScript Quiz URL http://www.aitech.ac.jp/~iteslj/quizzes/js/

Interactive JavaScript Quiz is a collection of Quizzes maintained by Charles I. Kelly, Aichi Institute of Technology, Toyota, Japan. These Quizzes are written by ESL teachers around the world in the form of plain text & then converted into JavaSricpt by Charles Kelly.

This site consists of 100 quizzes, and each quiz contains 20 to 100 questions. This site is mainly used to practice grammar, vocabulary and mechanic writing. The grammar quiz covers regular/irregular verbs, preposition, verb forms, question forms, sentence combining, modifiers, adverb often confused, and the like. Similarly, the Vocabulary quiz covers, antonym/synonym, homonym, word category, idiom with parts of body, phrasal verbs, etc; while the quiz for mechanic writing covers like punctuation & capitalization, and so on. There are many forms of Quizzes. They are multiple choices and matching, completion, spelling, hangman, shock wave, word cross puzzle, picture puzzle, etc. this site also links to other ESL quiz links. Last Quiz Added: May 17, 1999

d. Randall ESL Cyber Listening Lab. URL http://www.esl-lab.com/index.htm

This site is designed for both ESL/EFL students and teachers around the world. Registered members can chat in several different rooms, create their own unique profiles for others to look at, find pen friends via the WebBoard, and more. Teachers can use the Chat Center as part of classroom activities or as a means of communicating with other educators. In this site you can also find audio file library which stores various kinds of sounds. Copyright © 1998, 1999

e. CLTA Shocked Grammar URL http://www.clta.on.ca/hillsofmexico/shocked/homshocked01.htm

CLTA Shocked Grammar is one of CLTA services (CLTA stands for Centre for Language Training and Assessment). CLTA Shocked Grammar is a list of shockwave grammar games. There are 31 games here. They are suitable for beginner students. Another similar games can found at http://www.clta.on.ca/hillsofmexico/flash/homflash01.htm

3. The tutee role of computer

I hardly ever find web sites that represent what I mean by computer tutee role framework where the student can take control the web site or interface the program. So far, I found a web site that little represents this category. It is concordancer Space Less URL http://www.spaceless.com/concord/. In this site, the users can put their materials as data source for concordance program. In addition, the users can refer any other URL addresses as data source instead of what concordancer Space Less has.

D. Concluson

There are abundant web sites available for ESL/EFL teachers or students today. They are designed by teachers, students, programmers, researchers, and other experts with different rationale and pedagogy. What I am trying to do is to calcify them according to the programming features, what computer can and cannot do. From my small-scale observation, I found a huge number of web sites which function as tutor and tool in language learning. In contrast, the tutee role of web site is very scare. It might be due to that the tutee role of computer programming is difficult to put online. Otherwise, the observation I made should be expanded.

Classifying web sites according to the tutor-tool-tutee framework of computer role is useful for ESL/EFL teachers to help them decide easily and quickly the web sites that best fit their philosophy of teaching among thousands of web sites available on the web.

The future work can be directed to build up an ESL online resource database which is based on the tutor-tool-tutee framework of the computer role.

History, Congeniality and Follow the example of Javascript

Javascript introduced first time by Netscape in the year 1995. Initially this Language named " Live script" functioning as simple Language for browser Netscape Navigator 2. During the period this Language a lot of criticism since less be peaceful, its development is impressed in a hurry and no mistake message which presenting each time we make mistake at the (time) of compiling program. Then in line with its impetuous medium cooperation between Netscape and Sun during the period, hence Netscape give name "Javascript" to the Language at date of 4 December 1995. At the (time) of which jousting Microsoft by you try for this technological adapting is which they conceive of “Jscript" in browser internet explorer 3.
Javascript is formed Language of corps script which at its function walk at one particular document HTML, as long as Language of this internet Language is first Language script for web. This Language programming to give additional ability to of Language HTML with to allow execute commands beside user, what its meaning beside browser of non beside web.
Javascript base on browser (navigator) calling containing page yard web of Script from Javascript and of course insert in document HTML. Neither Javascript nor need special translator to run. Dissimilar the things of with Language "Java" (by the name of JavaScript always in differentiating) needing special translator to translate it beside User/client.

To be its clearer please download here...

Presenting ' Hello, World!' at screen

Steps make simple template program:
  1. Run software Microsoft Visual C++ 6.0 from Microsoft Visual Studio 6.0 (if need have recourse assistant)
  2. Select File menu -> New
  3. At dialogued by box select tab Projects, hereinafter:
    • Click Win 32 Console Application
    • Write name project, take example FirstProgram at stuffing Project_Name:
    • Determine directory of this place project be at Location: (possibility of filled with your directory home)
    • ClickOK
  4. Will emerge dialogue of box Win 32 Console Application:
    • Select radiobutton A “Hello, World!” application
    • Click Finish
    • Click OK
  5. At small window (generally on the left):
    • Click tab File View
    • Click sign + at FirstProgram files
    • Click sign + at Sourcefiles
    • DoubleClick at FirstProgram.cpp
  6. Select menu Build à Build Firstprogram.Exe or depress F7 at keyboard
  7. Select icon of exclamation mark (!), will emerge window console…

Reading the two integer and present its quantifying result

Guide:
  1. Use steps of making template program as in for step to five , but using Project_Name which differing, for example SecondProgram

  2. Change block program function play with following:
    int integer1; /* first number to be input by user */
    int integer2; /* second number to be input by user */
    int sum; /* variable in which sum will be stored */

    printf( "Enter first integer\n" ); /* prompt */
    scanf( "%d", &integer1 ); /* read an integer */

    printf( "Enter second integer\n" ); /* prompt */
    scanf( "%d", &integer2 ); /* read an integer */

    sum = integer1 + integer2; /* assign total to sum */

    printf( "Sum is %d\n", sum ); /* print sum */

    return 0; /* indicate that program ended successfully */

  3. Do step 6 and 7 template of such as program I.

Trying operator of equation and relationship operator


if ( num1 == num2 ) {
printf( "%d is equal to %d\n", num1, num2 );
} /* end if */
if ( num1 != num2 ) {
printf( "%d is not equal to %d\n", num1, num2 );
} /* end if */
if ( num1 < num2 ) {
printf( "%d is less than %d\n", num1, num2 );
} /* end if */
if ( num1 > num2 ) {
printf( "%d is greater than %d\n", num1, num2 );
} /* end if */
if ( num1 <= num2 ) {
printf( "%d is less than or equal to %d\n", num1, num2 );
} /* end if */
if ( num1 >= num2 ) {
printf( "%d is greater than or equal to %d\n", num1, num2 );
} /* end if */
return 0; /* indicate that program ended successfully */

How to configure Java Server Page runtime environment

NT installed JSP

Windows NT 4.0, Windows 2000 professional, windows 2000 server
Jdk1_2_2-001-win.exe
Tomcat.zip (3.0)

First, download the software JDK
Http://java.sun.com/products/jdk/1.2/
Tomcat
Http://jakarta.apache.org/builds/tomcat/release/v3.0/tomcat.zip

Second, the software is installed (a) JDK
1, double-click jdk1_2_2-001-win.exe document installation, the default configuration installed JDK the default installation directory is C: jdk1.2.
2, JRE default installation directory is C: Program FilesJavaSoftJRE1.2;
3, restart the computer;
4, the following update environmental variables: the C: directory jdk1.2.2 in additional to the PATH; the C: jdk1.2.2libools.jar; C: jdk1.2.2libdt.jar joined in the CLASSPATH.
Update: Control Panel -> -> environment -> System Variables;
(B) Tomcat
1, such as using WinZIP decompress tomcat.zip software to decompress to a directory, I decompress it to the C:, it will automatically create tomcat subdirectories, so that C was more of a directory on the C: / tomcat, I use the logo TOMCAT $ 3, modify Tomcat running of the port, to Tomcat to have a separate HTTP server, it must be used not to use a port, I have here the 8081 has not yet been occupied, I used $ TOMCAT_PORT logo, allocated to the Tomcat: 1) Open $ TOMCAT / server.xml; 2) Revise ContextManager: 4, double click on the directory $ TOMCAT startup.bat to start Tomcat 5 in the browser enter http://localhost: $ TOMCAT_PORT /, Tomcat Version 3.0 can see on this page that Tomcat installation is successful;

Hello, World!

Then use the same javac HelloWorld.java to compile this document, if there is no import javax.servlet .*
So that should be C: \ Tomcat \ common \ lib inside servlet.jar copy files to the C: \ JDK \ jre \ lib \ ext, again compiled, there will be no problem!
Tomcat then the directory C: \ Tomcat \ webapps \ ROOT inside the file structure as follows:
ROOT \ index.html
ROOT \ welcom.jsp
ROOT \ WEB-INF \ lib \ MyServlet.jar (If your servlet's. Fight a class. Jar file, on the lib below)
ROOT \ WEB-INF \ classes \ HelloWorld.class (HelloWorld.class the above documents generated on the inside)

Then enter http://localhost:8080/servlet/HelloWorld browser, the popular will and therefore Server error: Error 404 - Not Found
How all?
Servlet must use the C: \ Tomcat \ webapps \ ROOT \ WEB-INF directory of the following web.xml file registration with the EP open web.xml file,
On the inside to join

HelloWorld
HelloWorld


HelloWorld
/ Servlet / helloworld

This structure

HelloWorld
HelloWorld

That the designation includes servlet class.
And the following structure

HelloWorld
/ Servlet / HelloWorld

HelloServlet that should be designated where a URL mapping mode.
After revising the web.xml finished, restart Server, and then enter http://localhost:8080/servlet/HelloWorld, then lined a Hello, World! Waiting for you? Congratulate you get the:)
Amat, a tired hands, wrote on it here, it is hoped that role for beginners!

Java runtime maximize form and closed methods example

In fact, this was originally the basis of a java-related topics, but since it was raised, we might as well say a few words, the way also can be used as a reference for beginners.

/ / 1. Maximize form startup
/ / Frame1.java

Import java.awt .*;
Import java.awt.event .*;
Import javax.swing.UIManager;

Public class Frame1 extends WindowAdapter (
Public Frame1 () (
Frame f = new Frame ();
F.addWindowListener (this); / / f Frame1 set to deal with the incident
Dimension screenSize = Toolkit.getDefaultToolkit (). GetScreenSize () / / by the size of the screen
F.setLocation (0, 0);
F.setSize (screenSize.width, screenSize.height) / / set form the size of the size of the screen
F.setVisible (true);
)

Public static void main (String [] args) (
New Frame1 ();
)

Public void windowClosing (WindowEvent e) (
System.exit (0);
)
)

/ / 2. Closed form in the six methods
/ / 2.1. Use the enableEvents JFrame and processWindowEvent
/ / Frame1.java

Import java.awt .*;
Import java.awt.event .*;
Import javax.swing .*;

Public class Frame1 extends JFrame (
Public Frame1 () (
EnableEvents (AWTEvent.WINDOW_EVENT_MASK);
This.setSize (new Dimension (400, 300));
This.setTitle ( "Frame1");
)

Protected void processWindowEvent (WindowEvent e) (
Super.processWindowEvent (e);
If (e.getID () == WindowEvent.WINDOW_CLOSING) (
System.exit (0);
)
)
)

/ / 2.2. Interface directly to WindowListener
/ / Frame1.java

Import java.awt .*;
Import java.awt.event .*;

Public class Frame1 extends Frame implements WindowListener (
Public Frame1 () (
This.setSize (new Dimension (400, 300));
This.setTitle ( "Frame1");
This.addWindowListener (this);
)

Public void windowClosing (WindowEvent windowEvent) (
System.exit (0);
)
Public void windowOpened (WindowEvent windowEvent) ()
Public void windowClosed (WindowEvent windowEvent) ()
Public void windowIconified (WindowEvent windowEvent) ()
Public void windowDeiconified (WindowEvent windowEvent) ()
Public void windowActivated (WindowEvent windowEvent) ()
Public void windowDeactivated (WindowEvent windowEvent) ()
)

/ / 2.3. Directly inherited form adapter WindowAdapter
/ / Frame1.java

Import java.awt .*;
Import java.awt.event .*;

Public class Frame1 extends WindowAdapter (
Public Frame1 () (
Frame f = new Frame ();
F.setSize (new Dimension (400, 300));
F.setTitle ( "Frame1");
F.addWindowListener (this);
F.setVisible (true);
)
Public static void main (String [] s) (
New Frame1 ();
)
Public void windowClosing (WindowEvent windowEvent) (
System.exit (0);
)
)

/ / 2.4. Indirectly inherited form adapter WindowAdapter
/ / Frame1.java

Import java.awt .*;
Import java.awt.event .*;

Public class Frame1 extends Frame (
Public Frame1 () (
This.setSize (new Dimension (400, 300));
This.setTitle ( "Frame1");
This.addWindowListener (new winAdapter ());
This.setVisible (true);
)
Public static void main (String [] s) (
New Frame1 ();
)
)
(Class winAdapter extends WindowAdapter
Public void windowClosing (WindowEvent windowEvent) (
System.exit (0);
)
)

/ / 2.5. Indirectly achieve WindowListener Interface
/ / Frame1.java

Import java.awt .*;
Import java.awt.event .*;

Public class Frame1 extends Frame (
Public Frame1 () (
This.setSize (new Dimension (400, 300));
This.setTitle ( "Frame1");
This.addWindowListener (new winEventHandle ());
This.setVisible (true);
)
Public static void main (String [] s) (
New Frame1 ();
)
)
(Class winEventHandle implements WindowListener
Public void windowClosing (WindowEvent windowEvent) (
System.exit (0);
)
Public void windowOpened (WindowEvent windowEvent) ()
Public void windowClosed (WindowEvent windowEvent) ()
Public void windowIconified (WindowEvent windowEvent) ()
Public void windowDeiconified (WindowEvent windowEvent) ()
Public void windowActivated (WindowEvent windowEvent) ()
Public void windowDeactivated (WindowEvent windowEvent) ()
)

/ / 2.6. Use Inner Class
/ / Frame1.java

Import java.awt .*;
Import java.awt.event .*;

(Public class Frame1
Public Frame1 () (
Frame f = new Frame ();
F.addWindowListener (new WindowAdapter () (
Public void windowClosing (WindowEvent e) (
System.exit (0);
)
));
F.setSize (new Dimension (400, 300));
F.setVisible (true);
)

Public static void main (String [] s) (
New Frame1 ();
)
)

Server-Side Java with the Struts Framework on Mac OS X

Struts helps you organize your Java-based web applications by providing a framework based on a version of the Model-View-Controller design pattern. With Struts (or more formally, the Jakarta Project’s Struts Framework), you can combine Servlets, JSP, custom Struts tag libraries and other components using a unified framework that helps you design, create, and deploy stable web applications quickly. It requires a bit more work initially, to set everything up, but the value of the framework is realized later, when the ordered and componentized nature of your code lets you maintain, update, and reuse it easily.

Design Patterns and the Model-View-Controller Pattern

Design patterns are conceptual structures that you can use to better organize how you think about, plan, and talk about your code. Many applications, especially web applications, have core elements in common. Design patterns give developers a shared vocabulary, can help keep us from re-inventing versions of the same solutions for each new application.
Apple’s development environments have used the Model-View-Controller pattern for many years. Apple’s documentation includes a discussion of how the Model-View-Controller applies to Cocoa applications.
The Model-View-Controller pattern is used (whether implicitly or explicitly) in nearly every sophisticated web application. It’s a sensible way to organize your application architecture. Simply put, the Model is your data and your application logic, the View corresponds to your presentation elements (HTML, JSP, display beans, etc.), and the Controller(s) handle the application’s flow.


Installing and Using Struts on Mac OS X

To complete the installation steps below, you’ll need items on the Apple Developer Tools CD. So if you haven’t installed it yet, do so now.
To obtain Struts, go to http://jakarta.apache.org/struts/acquiring.html. In these examples, I’m using the current binary distribution, which at the time of this writing is 1.1. If you’re using a later version, then, of course, you’ll have to change some of the paths in the commands below.
First, use curl to download the Struts archive:
liz@localhost:/usr/local/src> curl -O  
http://jakarta.apache.org/builds/jakarta-struts/release/v1.1/jakarta-struts-1.1.tar.gz 
Next, extract the files using gnutar. The version of tar shipped with Mac OS X frequently does not work with tarfiles from the Apache project, but gnutar always will.
liz@localhost:/usr/local/src> gnutar -xzvf jakarta-struts-1.1.tar.gz
Before installing, check Jakarta’s list of prerequisites to make sure you have everything you need.
Struts requires a Java2 Java Development Kit - version 1.2 or later. Since you have installed the Apple Developer Tools, you’re all set. Struts also requires a servlet container. I’ve chosen to use the Apache Project’s Tomcat servlet container, and to run it as a stand-alone server for simplicity’s sake. At the time of this writing, the latest stable version was 4.1.24, although another major version is on the horizion. No matter which version you use, your installation process should be much like mine below.
Since the recent Developer Tools include a JDK greater than 1.4 (type java -version to find out which you have), I can install a lightweight version of Tomcat. I want the server to live under /usr/local/tomcat/, and the source tarball to stay in /usr/local/src.
liz@localhost:/usr/local/src> curl -O http://jakarta.apache.org/builds/jakarta-tomcat-4.0
                              /release/v4.1.24/bin/jakarta-tomcat-4.1.24-LE-jdk14.tar.gz
liz@localhost:/usr/local/src> gnutar -xzvf jakarta-tomcat-4.1.24-LE-jdk14.tar.gz
liz@localhost:/usr/local/src> sudo mkdir /usr/local/tomcat
Password:
liz@localhost:/usr/local/src> sudo mv jakarta-tomcat-4.1.24-LE-jdk14 /usr/local/tomcat
liz@localhost:/usr/local/src> export
CATALINA_HOME=/usr/local/tomcat/jakarta-tomcat-4.1.24-LE-jdk14
liz@localhost:/usr/local/src> cd $CATALINA_HOME/bin
liz@localhost:/usr/local/tomcat/jakarta-tomcat-4.1.24-LE-jdk14/bin> ./startup.sh
Now I can confirm that Tomcat is running on port 8080 on my local machine by going to http://localhost:8080 in a browser:

The next prerequisite is the Ant build system. Note that I’m still using gnutar to extract files, and not Apple’s standard tar executable. I’m installing Ant under /usr/local/ant, and adding its binary files directory to my $PATH environment variable.
liz@localhost:/usr/local/src> curl -O
http://apache.mirrorcentral.com/dist/ant/binaries/apache-ant-1.5.3-1-bin.tar.gz
liz@localhost:/usr/local/src> gnutar -xzvf apache-ant-1.5.3-1-bin.tar.gz 
liz@localhost:/usr/local/src> sudo mkdir /usr/local/ant 
liz@localhost:/usr/local/src> sudo mv apache-ant-1.5.3-1 /usr/local/ant/ 
liz@localhost:/usr/local/src> export ANT_HOME=/usr/local/ant/apache-ant-1.5.3-
liz@localhost:/usr/local/src> export PATH=$PATH:$ANT_HOME/bin/
At this point, if you’ve been following along with me, you’ve set up two environment variables ($CATALINA_HOME and $ANT_HOME) and changed one ($PATH). When you exit your terminal session, these variables will go away. No fun. You’ll probably want to set up a shell startup file that loads these variables for you on each new terminal session. Since I use the bash shell, my startup file lives in /Users/liz/.bash_profile and looks (in part) like this:
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/libexec:/System/Library/CoreServices 
export JAVA_HOME=/usr 
export PS1="\u@\h:\w> "
Since I wanted to keep the new environment variables for future use, I changed my .bash_profile to contain the lines below. You can also see that I added aliases for starting and stopping tomcat.
export ANT_HOME=/usr/local/ant/apache-ant-1.5.3-1 
export CATALINA_HOME=/usr/local/tomcat/jakarta-tomcat-4.1.24-LE-jdk14   
export  PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/libexec:  
/System/Library/CoreServices:$ANT_HOME/bin   
export JAVA_HOME=/usr   
alias start_tomcat='$CATALINA_HOME/bin/startup.sh' 
alias stop_tomcat='$CATALINA_HOME/bin/shutdown.sh'
If you’re using the bash shell, you can copy and use this file as is. Otherwise, see the manpage for your favorite shell program (for example, man tcsh). To use bash and the .bash_profile file I’m using, open the Terminal application, click Preferences, and set your preferences to be like these:

It’s finally time to install Struts itself. The version of Tomcat I’m using comes with an integrated version of Struts. Still, there are some tag library descriptors and example files that I want to install. Note: If you aren’t using Tomcat (or if you’re using an older version of Tomcat without Struts), follow the Struts installation guide. You’ll just have to copy a few extra files - it’s not much harder.
Here are the commands I used to add the extra Struts files to my new Tomcat installation. Again, if you aren’t using Tomcat with Struts built-in, see the installation link in the line above.
liz@localhost:~> stop_tomcat 
liz@localhost:~> cd /usr/local/src/jakarta-struts-1.1   
liz@localhost:/usr/local/src/jakarta-struts-1.1>   
cp lib/*.tld $CATALINA_HOME/server/webapps/admin/WEB-INF/ 
liz@localhost:/usr/local/src/jakarta-struts-1.1>   
cp webapps/*.war $CATALINA_HOME/webapps 
liz@localhost:/usr/local/src/jakarta-struts-1.1> start_tomcat
With that step completed, you should be able to view the example applications (which came bundled in those .war files referenced above). For example, look at http://localhost:8080/struts-example/index.jsp


”Hello World”
Now we can build a “hello world” mini-application, using a few Struts components. Since the setup process is fairly complicated, this simple application won’t take advantage of many of Struts’ useful features. I’ll focus on those in the next section.
One of the .war files in your Struts source directory is called struts-blank.war. This file is meant to serve as a template for new Struts applications. I want to extract the archive so I can modify it to make my own simple “Hello World” application. So I copy struts-blank.war into a new empty folder, and type jar -xf struts-blank.war. Here are the contents:

You can see that the archive includes the struts.jar file (necessary for any Struts application), some tag libraries, the standard web.xml and manifest files, and a configuration file called struts-config.xml. This config file is actually functionally empty, but it includes lots of useful examples in commented sections.
Let’s look at the other two files in the archive. First, the index.jsp file that comes with the blank Struts application. In this file, you can see the Struts tag libraries in use. (If you aren’t familiar with the taglibs concept yet, you may want to read Sun’s explanation.) One interesting thing to note is that all the English text on the page is stored separately and presented via a custom tag. While this is by no means required in a Struts application, it does simplify Internationalization or text changes. You don’t need to touch any Java components in order to alter the page copy.
<%@ page language="java" %>   
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>   
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>   
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>       
<html:html locale="true">   
<head>   
<title><bean:message key="index.title"/></title>   
<html:base/>    </head>    <body bgcolor="white">       
<logic:notPresent name="org.apache.struts.action.MESSAGE" scope="application">     
<font color="red">       
ERROR:  Application resources not loaded -- check servlet container      
logs for error messages.     
</font>   
</logic:notPresent>       
<h3><bean:message key="index.heading"/></h3>   
<p><bean:message key="index.message"/></p>       
</body>   
</html:html>
The copy for the file above is stored in ApplicationResources.properties. Since I’m making my own application, I’ll start by altering that text. Here are the contents of my new properties file:
index.title=My Own Hello World, Using Struts  index.heading=Heya
Next, I want to make a simple Java Bean that my application can reference. It’s about as simple as a Bean gets - it stores a hard-coded Magic Number, and tells the user whether or not they guessed that number correctly.
package foo;   
public class GuessBean  
{
public int magicNumber;         
public GuessBean()      
{         
this.magicNumber = 2;     
}       
public String evaluateGuess(int g)      
{        
if (g == this.magicNumber)        
{           
return "You guessed it!";        
}        
else       
{          
return "Sorry, wrong number.";       
}     
}   
}
Now I can edit the index.jsp file and add a basic form, and create a new file called guess.jsp which calls the bean’s evaluateGuess() method. (You can find those files in the hello.war archive.)
The final step is to create a build.xml file that Ant can use to bundle the all application’s files into a WAR archive, and deploy them to Tomcat. If you are using a Java IDE that can build WAR files for you, you won’t need to bother with this section. Otherwise, here’s the build file:
<project name="hello world" default="build-all" basedir=".">     
<property environment="env"/>   
<property name="appname" value="hello"/>   
<property name="src.dir" value="${basedir}/WEB-INF/src"/>   
<property name="app.name" value="hello"/>   
<property name="app.path" value="/${app.name}"/>   
<property name="app.version" value="0.1-dev"/>   
<property name="build.dir" value="${basedir}/build"/>   
<property name="classes.dir" value="${basedir}/WEB-INF/classes"/>   
<property name="tomcat.home" value="${env.CATALINA_HOME}"/>   
<property name="servlet.jar" value="${tomcat.home}/common/lib/servlet.jar"/>   
<property name="deploy.dir" value="${tomcat.home}/webapps"/>           
<path id="build.path">         
<fileset dir="./WEB-INF/lib/">             
<include name="**/*.jar"/>         
</fileset>         
<pathelement path="${src.dir}"/>         
<pathelement path="${servlet.jar}"/>         
<pathelement path="${classes.dir}"/>     
</path>           
<target name="cleanlocal">           
<delete dir="${build.dir}" includeEmptyDirs="true" />           
<delete file="${appname}.war" />           
<mkdir dir="${build.dir}"/>       
</target>                     
<target name="compile">         
<javac   srcdir="${src.dir}" destdir="${classes.dir}" debug="on" deprecation="on">           
<include name="**/*.java"/>           
<classpath refid="build.path"/>         
</javac>       
</target>           
<target name="cleanserver">         
<delete file="${deploy.dir}/${appname}.war" />           
<delete  dir="${deploy.dir}/${appname}" includeEmptyDirs="true" />       
</target>           
<target name="war">           
<war warfile="${appname}.war" webxml="./WEB-INF/web.xml">                  
<fileset dir="./" includes="**/*.*" excludes="*.war, **/*.nbattrs,
.xml, **/WEB-INF/**/*.*, **/project-files/**/*.*"/>                  
<webinf  dir="./WEB-INF"    includes="**/*" excludes="web.xml,                    
**/*.jar, **/*.class"/>                  
<lib dir="./WEB-INF/lib"/>                  
<classes dir="${classes.dir}" cludes="**/*.properties, **/*.class" />           
</war>       
</target>           
<target name="build-all" depends="cleanlocal, cleanserver, compile, war">         
<copy file="${appname}.war" todir="${tomcat.home}/webapps"/>       
</target>    
</project>
To deploy my new application, I simply need to run Ant and restart Tomcat.
liz@localhost:~/hello> ant  liz@localhost:~/hello> stop_tomcat 
liz@localhost:~/hello> start_tomcat

Sample Application: A RSS Newsfeed Consolidator

Many news sites and weblogs make their headlines available as RSS feeds. The RSS format is (more-or-less standardized) XML, generally made available over HTTP. You can read more about RSS, for example, on the O’Reilly xml.com site and the webreference.com site (and elsewhere).
In this section, I’ll show you how you can use Servlets, JSP, and Struts to create an application that will allow a user to log in, assemble a list of weblogs and/or news sites, and read headlines fetched and displayed by the application. Headlines are links to the remote content. For simplicity’s sake, I’ve left off several real-world aspects of the application, most notably the database backend. User data is simply stored in the session, and vanishes when the user closes their browser or you re-start Tomcat.
Let’s look at the application with the Model-View-Controller design paradigm in mind. In this case, the model is the session data plus the application logic. The view corresponds to the JSP pages and beans used for display, and the controller is a special SiteAction class. The SiteAction class is a subclass of a Struts Action class, and it is responsible for handling user input and dispatching requests to the correct places. Here’s an overview of the files which make up the application. (You can download the WAR file and a tarball of the whole application.)

In this application, I want to take advantage of a few of Struts’ cooler features. For instance, I can create custom Form Beans and tie them to Action objects. Let’s start with a Form Bean. The bean’s properties map to form fields, and each property has appropriately-named accessor methods.
package foo;   
import javax.servlet.http.HttpServletRequest; 
import org.apache.struts.action.ActionError; 
import org.apache.struts.action.ActionErrors; 
import org.apache.struts.action.ActionForm; 
import org.apache.struts.action.ActionMapping;   
public final class SiteForm extends ActionForm  
{           
private String index = null;     
private String url = null;     
private String title = null;     
private String dispatch = null;      
// accessor methods       
public void setUrl(String url)      
{         
this.url = url;     
}       
public void setTitle(String title)      
{         
this.title = title;     
}       
public void setIndex(String index)      
{         
this.index = index;     
}       
public void setDispatch(String dispatch)     
{         
this.dispatch = dispatch;     
}       
public String getUrl()      
{         
return (this.url);     
}       
public String getTitle()      
{         
return (this.title);     
}       
public String getIndex()      
{         
return (this.index);     
}       
public String getDispatch()     
{         
return (this.dispatch);     
}       
public void reset(ActionMapping mapping, HttpServletRequest request)      
{        
this.url = null;        
this.title = null;        
this.index = null;     
}     
// for this application, we aren't validating user input, but you could easily extend      
this method to do form validation public ActionErrors validate(ActionMapping mapping,                                  
HttpServletRequest request)      
{       
// I'm leaving this example code in place so you can        
see how form validation would be done using Struts           
ActionErrors errors = new ActionErrors();        
// if (url == null)          
//    errors.add("url", new ActionError("error.url.required"));         
return errors;       
}  
One of the most interesting things about Struts is its set of Action classes. The code below extends the Struts Action class, and uses simple conditionals to dispatch user requests. There are other kinds of Action classes, notably DispatchAction, which you can read about in the Struts user guide and on Ted Husted’s husted.com.
// this controller responds to user input, handles it, and redirects  
// to a location specified in struts-config.xml  package foo;     
import java.io.IOException;  import java.util.Vector; 
import javax.servlet.RequestDispatcher; 
import javax.servlet.ServletException; 
import javax.servlet.http.HttpServletRequest; 
import javax.servlet.http.HttpSession; 
import javax.servlet.http.HttpServletResponse; 
import org.apache.struts.action.Action; 
import org.apache.struts.action.ActionError; 
import org.apache.struts.action.ActionErrors; 
import org.apache.struts.action.ActionMapping; 
import org.apache.struts.action.ActionForm; 
import org.apache.struts.action.ActionForward;   
public final class SiteAction extends Action
{       
public ActionForward perform(ActionMapping mapping,                  
ActionForm form,                  
HttpServletRequest request,                  
HttpServletResponse response)     
throws IOException, ServletException      
{       
ActionErrors errors = new ActionErrors();     
// get the RSS Site List object from the session,       
or create a new one if necessary     
HttpSession session = request.getSession();     
SiteList siteList = (SiteList)session.getAttribute("siteList");     
if (siteList == null)     
{         
siteList = new SiteList();     
}       
String dispatch = ((SiteForm) form).getDispatch();       
String forward = "alter";       
if ("add".equals(dispatch))      
{         
String url = ((SiteForm) form).getUrl();         
String title = ((SiteForm) form).getTitle();         
if (url != null && title != null)         
{             
SiteListItem it = new SiteListItem();             
it.setURL(url);             
it.setTitle(title);             
siteList.addSite(it);         
}     
}     
else if ("show".equals(dispatch))      
{         
String index = ((SiteForm) form).getIndex();         
if (index != null)         
{             
// put the selected site index in the              
session for use by the next page             
session.setAttribute("siteIndex",index);             
forward = "view";         
}     
}     
else if ("delete".equals(dispatch))     
{         
String index = ((SiteForm) form).getIndex();         
if (index != null)         
{             
int ind = Integer.parseInt(index);             
siteList.removeSite(ind);         
}     
}       
// Forward to the specified success URL      
return (mapping.findForward(forward));     
} 
}
At this point, we tie the Action and Form objects together using directives in struts-config.xml
<?xml version="1.0" encoding="ISO-8859-1" ?>   
<!DOCTYPE struts-config PUBLIC           
"-//Apache Software Foundation//DTD Struts Configuration 1.0//EN"           
"http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd"> 
<struts-config>     
<!-- ========== Form Bean Definitions =================================== -->   
<form-beans>       
<!-- our SiteList controller -->     
<form-bean name="SiteForm" type="foo.SiteForm"/>       
</form-beans>       
<!-- ========== Action Mapping Definitions ============================== -->   
<action-mappings>       
<action path="/siteAction" type="foo.SiteAction" name="SiteForm">        
<forward name="alter" path="/index.jsp"/>        
<forward name="view"  path="/show.jsp"/>     
</action>       
</action-mappings>   
</struts-config
Now we can use Struts to create a JSP page with user input elements that call the SiteAction object.
<%@ page language="java" %> 
<%@ page import="foo.SiteListItem" %> 
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> 
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> 
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>   
<head> 
<title>Manage Sites</title> 
<html:base/> 
</head> 
<body bgcolor="white">   
<logic:notPresent name="org.apache.struts.action.MESSAGE" scope="application">   
<font color="red">
ERROR:  Application resources not loaded -- check servlet container     
logs for error messages.</font> 
</logic:notPresent> <br />   
<jsp:useBean id="login" scope="session" class="foo.LoginBean" />   
<jsp:useBean id="siteList" scope="session" class="foo.SiteList" />   
<h1>RSS Site Manager</h1>   
<%// user validation is being handled by a session bean if (login.validate() == false)     
{        
out.println("<script language=\"javascript\">         
document.location='/headlines/login.jsp'</script>");       
return;     
}        
int size = siteList.getSize();       
for (int i=0; i < size; i++)     
{         
SiteListItem it = siteList.getItemAt(i);         
out.println("<a href=\"/headlines/siteAction.do?dispatch=show&index="           
+ i + "\">" + it.getTitle() +            "
</a><br>");     
}   
%> 
<br> 
<hr> 
<h2>Add a Site</h2> 
<html:form type="foo.SiteAction" name="SiteForm" action="/siteAction.do" focus="url"> 
<table border="0"><tr>     
<td>RSS URL</td>     
<td><input type="text" name="url" size="60"/></td>  </tr>  <tr>     
<td>Title</td>      <td><input type="text" name="title" size="60"/></td>   
</tr>  <tr>      <td colspan="2"> <input type="submit" value="Submit"/></td>  </tr>   
</table>  <input type="hidden" name="dispatch" value="add">  </html:form>  </body> 
</html:html>
These files work together with beans that store and parse the list of RSS links and manage user login. Those helper objects are available in the tar archive. Note that in a production-quality application, user logins would have been handled by an Action object instead of the lightweight bean I’m using for example purposes.

With all these pieces assembled, you can compile and deploy the application using the same build.xml file referenced above. Just change the project name and appname at the top of the file, and you’re good to go. Here’s the RSS manager in action:

Conclusion, and Suggestions for Further Reading

This article has given you the information you need to get up and running with Struts on Mac OS X. Still, there’s much more to Struts than I can cover in one article. If you’re interested in learning more, visit the Struts User Guide. You might also want to pick up Programming Jakarta Struts, by Chuck Cavaness, or Struts in Action, by Ted Husted. Finally, I would be remiss in not recommending the now-classic book Design Patterns: Elements of Reusable Object-Oriented Software by Gamma, Helm, Johnson, and Vlissides.

JSP Quick-Start Guide for Linux

Downloading and Installing Tomcat


Since Apache doesn't support JSP out of the box, we need to add something else to the mix to provide that support. Unfortunately, JSP is too complicated to be supported by a simple Apache module; thus, we need to install an entirely new program to provide that support, then instruct Apache to forward requests for JSP pages to that program (note: this may sound like CGI, but it isn't; just wait and see). The program we'll be using is called Tomcat, and is also written by the Apache Group.

Tomcat is in fact a simple Web server in its own right. It doesn't support any of the advanced features of Apache, however; that's not its job! By linking Tomcat and Apache together, you get a system that provides full support for JSP (thanks to Tomcat) while maintaining the performance and expandability (PHP, Perl, SSL, etc.) of Apache.


Your first step should be to download and install the Java 2 Software Development Kit (Java 2 SDK) from Sun. This is required both to run Tomcat (which is a Java program), and for Tomcat to be able to compile JSPs for use. The current version of the Java 2 SDK (also called the JDK) as of this writing is version 1.4.1_01, and is available for download here. Download the ~42MB "Linux self-extracting file" (be sure to download the SDK, not the JRE!). The filename should be j2sdk-1_4_1_01-linux-i586.bin. Extract this file into your /usr/local directory with this series of commands:

[kevin@sp kevin]$ su

Password: ********

[root@sp kevin]# chmod u+x j2sdk-1_4_1_01-linux-i586.bin

[root@sp kevin]# mv j2sdk-1_4_1_01-linux-i586.bin /usr/local/

[root@sp kevin]# cd /usr/local

[root@sp local]# ./j2sdk-1_4_1_01-linux-i586.bin

You can delete the j2sdk-1_4_1_01-linux-i586.bin file now, or put it someplace safe for future use; you're done with it.

Java is now installed, but you need to do a few things to settle it smoothly into your system. First, make a symbolic link so you can access the Java installation with the easier-to-type name /usr/local/java:

[root@sp local]# ln -s j2sdk1.4.1_01 java

Next, make links to the important programs that make up the Java SDK in the /usr/local/bin directory, so you can run them from anywhere:

[root@sp local]# ln -s java/bin/java /usr/local/bin/java

[root@sp local]# ln -s java/bin/javac /usr/local/bin/java

[root@sp local]# ln -s java/bin/jar /usr/local/bin/java

Now, we need to edit a couple of environment variables on your system. Still as root, open the /etc/profile on your system in your preferred text editor. Look for a line beginning with PATH=. When you type a program name at the command prompt, this line sets the directories that your system checks for that program. Check to make sure /usr/local/bin is in the list. If it isn't, add the following line right after the existing PATH= line:

PATH="$PATH:/usr/local/bin"

You also need to set the JAVA_HOME environment variable to point to your Java installation. To do this, scroll right down to the bottom of the file and add these two lines to the end:

JAVA_HOME="/usr/local/java"

export JAVA_HOME

Save the changes, log out, and then log back in. Java should now be nicely installed and integrated with your system. To test it, you can type java -version at the command prompt and make sure that it reports your Java version correctly.

Now you're ready to install Tomcat. Download the latest release from the Jakarta Project Web site. As of this writing, the latest version was 4.1.18, and was available at http://jakarta.apache.org/builds/jakarta-tomcat-4.0/release/v4.1.18/bin/. The file should be called jakarta-tomcat-4.1.18-LE-jdk14.tar.gz, and is about 5.1MB.

Once you've downloaded the file, move it to your /usr/local directory and extract it:

[kevin@sp kevin]$ su

Password: ********

[root@sp kevin]# mv jakarta-tomcat-4.1.18-LE-jdk14.tar.gz /usr/local/

[root@sp local]# tar xfz jakarta-tomcat-4.1.18-LE-jdk14.tar.gz

You can delete the jakarta-tomcat-4.1.18-LE-jdk14.tar.gz file now, or put it somewhere safe for future use; you're done with it.

As with the Java SDK, create a link to the installation directory with a neater name for convenience:

[root@sp local]# ln -s jakarta-tomcat-4.1.18-LE-jdk14 tomcat

Like Java, Tomcat requires an environment variable of its own to be set for it to run properly. Open up your /etc/profile file one more time and add these two lines to the end:

CATALINA_HOME="/usr/local/tomcat"

export CATALINA_HOME

Once again, save your changes, log out, then log back in for changes to take effect.

You're ready to start Tomcat! Log in as root and type the following command to launch it:

[root@sp kevin]# $CATALINA_HOME/bin/startup.sh

If all goes well, the startup.sh script should display the values of a few environment variables, and then Tomcat will launch quietly in the background. Congrats -- Tomcat is up and running!

As I said before, Tomcat provides its own simple Web server, and we can use this to test that it is working properly. Tomcat's Web server is set up to use port 8080 by default, so open your Web browser and load http://localhost:8080/. You should see the Tomcat home page, with links to some examples that come preinstalled on the server.

Have a play with these examples if you're curious, and notice how the JSP examples take considerable time to load the first time you use them, but then work very quickly upon subsequent accesses. This happens because the first time a JSP page is accessed, Tomcat needs to compile it into a Java Servlet, which is a piece of pure Java code that can be run very quickly to process requests. That Servlet is then held in memory to process subsequent requests for the same JSP at blazing speed.

When you're done playing with Tomcat, shut it down by running the shutdown.sh script the same way you ran the startup.sh script above ($CATALINA_HOME/bin/shutdown.sh). Tomcat will shut down after a few moments.

Running Tomcat Automatically

If you've got Apache running automatically at system start-up, you'll probably want to do the same for Tomcat. Start by copying (not linking) the catalina.sh script that came with Tomcat to your /etc/init.d/ directory:

[root@sp kevin]# cd /etc

[root@sp etc]# cp /usr/local/tomcat/bin/catalina.sh init.d/

This script relies on the JAVA_HOME and CATALINA_HOME environment variables we set earlier, but these variables do not exist while the system is starting up. We must therefore edit the script a little so that it can serve as a system startup script.

Open the file in your favourite text editor, and scroll down to the first blank line following the opening comments (any line that begins with a # is a comment). Add these two lines at that point:

JAVA_HOME="/usr/local/java"

CATALINA_HOME="/usr/local/tomcat"

This script actually makes an attempt at detecting CATALINA_HOME itself, but this attempt backfires if the script is not actually in the Tomcat directory (which in this case it isn't). Scroll down and look for a line that begins with CATALINA_HOME=. It should look like this:

CATALINA_HOME=`cd "$PRGDIR/.." ; pwd`

Comment it out by putting a # at the start of that line:

#CATALINA_HOME=`cd "$PRGDIR/.." ; pwd`

That completes the adjustments to catalina.sh. You can now assign this as a start-up script in the various runlevels (operating modes) of your computer:

[root@sp etc]# ln -s init.d/catalina.sh rc2.d/S90tomcat

[root@sp etc]# ln -s init.d/catalina.sh rc3.d/S90tomcat

[root@sp etc]# ln -s init.d/catalina.sh rc4.d/S90tomcat

[root@sp etc]# ln -s init.d/catalina.sh rc5.d/S90tomcat

[root@sp etc]# ln -s init.d/catalina.sh rc0.d/K19tomcat

That should do it! To try it out, shut down your computer, start it back up again, and see if you can load the Tomcat home page at http://localhost:8080/.

A Simple JSP

Okay, playing with the examples can be fun (spoiler: the two colours you're looking for are Black and Cyan), but the real test is to set up a JSP of your own and make it run.

Open NotePad or your favourite text editor, and type in the following:

This example brought to you by JSP and SitePoint.com!

Save the file as theEnd.html in a new subdirectory of Tomcat's webapps directory called sitepoint. Create a second new file in NotePad and type in the following:


<%@ page language="Java" %>

<html>

<head>

<title>A Simple JSP</title>

</head>

<body>

<p>

 <% String num = request.getParameter("num");

    if (num == null) { // No number specified

      // Display the form

 %>

      <form action="<%= HttpUtils.getRequestURL(request) %>">

      What should I count to? <input type="text" size="2" name="num" />

      <input type="submit" />

      </form>

 <%

    } else for (int i=1; i<=Integer.parseInt(num); i++) {

 %>

      Counting: <%= i %><br />

 <% }

 %>

</p>



<%@ include file="theEnd.html" %>



</body>

</html>

Save this as count.jsp in your new sitepoint directory alongside theEnd.html.

Now, to make these two files visible, you need to create a Java Web application to contain them. Doing this is nice and simple. Create a subdirectory of your new sitepoint directory called WEB-INF. In that subdirectory, create a text file called web.xml and type the following into it:

<?xml version="1.0" encoding="ISO-8859-1"?>



<!DOCTYPE web-app

   PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"

   "http://java.sun.com/dtd/web-app_2_3.dtd">



<web-app>

</web-app>

Save the file and then restart Tomcat or reboot your system to allow Tomcat to become aware of the new Web application. You can then view the page through Tomcat with the URL http://localhost:8080/sitepoint/count.jsp.

To make your new Web application visible through Apache, simply restart Apache. When you restarted Tomcat, it created a new automatic configuration file for Apache; restarting Apache will read in this new config file and add your new Web application to the lineup. Whenever you add a new Web application to Tomcat you need to perform this "Restart Tomcat, Restart Apache" process; fortunately, this doesn't happen often.

Once Apache is back up and running, open http://localhost/sitepoint/count.jsp. There you have it: your first working JSP in Apache!

System Requirements Software - Java 2 SDK Standard Edition 1.4.2

Software - Java 2 SDK Standard Edition, 1.4.2 is supported on i586 Intel and 100% compatible platforms running Microsoft Windows. For a list of supported operating systems and desktop managers, see System Configurations.
Hardware - Intel and 100% compatible processors are supported. A Pentium 166MHz or faster processor with at least 32 megabytes of physical RAM is required to run graphically based applications. At least 48 megabytes of RAM is recommended for applets running within a browser using the Java Plug-in. Running with less memory may cause disk swapping which has a severe effect on performance. Very large programs may require more RAM for adequate performance.
For the amount of disk space required, see Windows Disk Space Requirements.
Note -- Trying to install the Java 2 SDK on a non-supported version of Microsoft Windows or on a machine that doesn't have a sufficiently up-to-date Service Pack will cause the installer to generate this warning: "We recommend that you do not install this Java Platform for the following reasons: This Java Platform does not support the operating system or operating-system service pack on this machine."

Installation Instructions

In this procedure, you will run the self-installing executable to unpack and install the Java 2 SDK software bundle. As part of the Java 2 SDK, this installation includes the Java Plug-in and Java Web Start, as well as an option to include the public Java 2 Runtime Environment. (The Java 2 SDK also contains a private J2RE for use only by its tools.)
For issues related to Windows Installation (IFTW) and Java Update, see the Windows Installation (IFTW) and Java Update FAQ. See this note on Proxy Settings and Authentication.
Print or bookmark these instructions - After the Java 2 SDK software has been installed, you may be asked to reboot your system. To continue using these instructions after rebooting, either print this page now, bookmark it now, or use your Web browser's history function to get back to this page.
Troubleshooting - If you have any difficulties, see the Troubleshooting section at the end of this document or submit a bug report for your installation problem.
Note: For any text on this page containing the following notation, you must substitute the appropriate update version number for the notation.
For example, if you are downloading the installer for update 1.4.2_01, the following file name:
j2sdk-1_4_2_-windows-i586.ex
would become:
j2sdk-1_4_2_01-windows-i586.exe
1. Check the download file size (Optional)
If you save the self-installing executable to disk without running it from the download page at the web site, notice that its byte size is provided on the download page. Once the download has completed, check that you have downloaded the full, uncorrupted software file.
2. If 1.4.2 Beta is installed, uninstall it.
Use the Microsoft Windows Add/Remove Programs utility, accessible from the Control Panel (Start -&gt; Settings -&gt; Control Panel).
3. Run the Java 2 SDK installer
Note - you must have administrative permissions in order to install the Java 2 SDK on Microsoft Windows 2000 and XP.
The file j2sdk-1_4_2_-windows-i586-i.exe is the Java 2 SDK installer. If you downloaded it instead of running it directly from the web site, double-click on the installer's icon. Then follow the instructions the installer provides. The installer may ask you to reboot your computer.

When done with the installation, you can delete the download file to recover disk space.
Note -- Trying to install the Java 2 SDK on a non-supported version of Microsoft Windows or on a machine that doesn't have a sufficiently up-to-date Service Pack will cause the installer to generate this warning: "We recommend that you do not install this Java Platform for the following reasons: This Java Platform does not support the operating system or operating-system service pack on this machine." See the system requirements above for information on supported configurations of Microsoft Windows.
Installed Directory Tree

The Java 2 SDK has the directory structure shown below.




                  j2sdk1.4.2_
____________________|___________________
|    |    |    |    |   |     |      |   |
|    |    |    |   bin lib    |    demo  |
|    |    | LICENSE |   |     |         jre
|    | COPYRIGHT              |        __|__
|  README.txt              include    |     |
readme.html                           bin   lib
In addition, the Java Plug-in and Java Web Start will automatically be installed. Look for a Java Web Start icon on your desktop. There will also be an entry for Java Web Start in the Start -&gt; Programs menu.
Java Web Start --
  • Compatibility: The release of Java Web Start that comes with this SDK/JRE can be run on SDK/JRE 1.2.2 or later. It will not work with SDK/JRE 1.1.x or earlier.

  • Upgrading from Previous Versions: If you have a previous release of Java Web Start, do not uninstall it. Uninstalling it will cause the download cache to be cleared, and all previously installed Java Web Start application data will have to be downloaded again. This new release will overwrite previous installations and automatically update browsers to use this new release. The configuration files and program files folder used by Java Web Start have changed, but all your settings will remain intact after the upgrade, since Java Web Start will translate your settings to the new form.

  • Uninstalling 1.4.2 SDK/JRE: The only way to uninstall Java Web Start 1.4.2 is to uninstall the 1.4.2 SDK/JRE. But note that doing so will remove the 1.4.2 Java Web Start cache, which stores the Java Web Start application data. Uninstalling the SDK/JRE will not, however, remove the cache for previous releases of Java Web Start (1.0.1 and 1.2). Previous releases have separate uninstallers for Java Web Start.

  • Using Java Web Start with Netscape 6.x/7.x: For Netscape 6.x/7.x users, setup the Java Web Start MIME type (JNLP) in the Edit-&gt;Preferences-&gt;Navigator-&gt;Helper Applications section. The file extension is jnlp; MIME Type is application/x-java-jnlp-file. It should be handled by the javaws executable file in your Java Web Start directory. Also note that, due to a problem with the JavaScript in Netscape 6.x/7.x, you must use the non-JavaScript version of the demos page.
4. If you want to run Netscape 7.x/Mozilla 1.x with Java Plug-in, do this:
  • Exit the Netscape 7.x/Mozilla 1.x browser and all Netscape 7.x/Mozilla 1.x "objects" (Messenger, Composer ...);

  • If the Quick Launch feature is enabled, disable it;

  • Then restart Netscape 7.x/Mozilla
5. Update the PATH variable (Optional)
You can run the Java 2 SDK without setting the PATH variable, or you can optionally set it as a convenience.
Should I set the PATH variable?

Set the PATH variable if you want to be able to conveniently run the Java 2 SDK executables (javac.exe, java.exe, javadoc.exe, etc.) from any directory without having to type the full path of the command. If you don't set the PATH variable, you need to specify the full path to the executable every time you run it, such as:
C:&gt; \j2sdk1.4.2_\bin\javac MyClass.java
It's useful to set the PATH permanently so it will persist after rebooting.
How do I set the PATH permanently?

To set the PATH permanently, add the full path of the j2sdk1.4.2_\bin directory to the PATH variable. Typically this full path looks something like C:\j2sdk1.4.2_\bin. Set the PATH as follows, according to whether you are on Microsoft Windows NT or 98/2000/ME.
Microsoft Windows NT, 2000, and XP - To set the PATH permanently:
  1. Choose Start, Settings, Control Panel, and double-click System. On Microsoft Windows NT, select the Environment tab; on Microsoft Windows 2000 select the Advanced tab and then Environment Variables. Look for "Path" in the User Variables and System Variables. If you're not sure where to add the path, add it to the right end of the "Path" in the User Variables. A typical value for PATH is:

         C:\j2sdk1.4.2_\bin
    Capitalization doesn't matter. Click "Set", "OK" or "Apply".
  2. The PATH can be a series of directories separated by semi-colons (;). Microsoft Windows looks for programs in the PATH directories in order, from left to right. You should only have one bin directory for a Java SDK in the path at a time (those following the first are ignored), so if one is already present, you can update it to j2sdk1.4.2_\bin.
  3. The new path takes effect in each new Command Prompt window you open after setting the PATH variable.
Microsoft Windows 98 - To set the PATH permanently, open the AUTOEXEC.BAT file and add or change the PATH statement as follows:
    1. Start the system editor. Choose "Start", "Run" and enter sysedit, then click OK. The system editor starts up with several windows showing. Go to the window that is displaying AUTOEXEC.BAT

    2. Look for the PATH statement. (If you don't have one, add one.) If you're not sure where to add the path, add it to the right end of the PATH. For example, in the following PATH statement, we have added the bin directory at the right end:

    3. PATH C:\WINDOWS;C:\WINDOWS\COMMAND;C:\J2SDK1.4.2_\BIN
      Capitalization doesn't matter. The PATH can be a series of directories separated by semi-colons (;). Microsoft Windows searches for programs in the PATH directories in order, from left to right. You should only have one bin directory for a Java SDK in the path at a time (those following the first are ignored), so if one is already present, you can update it to j2sdk1.4.2_.

    4. To make the path take effect in the current Command Prompt window, execute the following:
    C:> c:\autoexec.bat

    To find out the current value of your PATH, to
    see if it took effect, at the command prompt, type:

    C:> path

Microsoft Windows ME - To set the PATH permanently:
From the start menu, choose programs, accessories, system tools, and system information. This brings up a window titled "Microsoft Help and Support". From here, choose the tools menu, then select the system configuration utility. Click the environment tab, select PATH and press the edit button. Now add the SDK to your path as described in step b above. After you've added the location of the SDK to your PATH, save the changes and reboot your machine when prompted.
6. Start using the Java 2 SDK!
Your computer system should now be ready to use the Java 2 SDK. In this step, you'll run some simple commands to make sure it is working properly.
If you are new to developing and running programs in the Java programming language, see The Java Tutorial online for some guidance. Note especially the tutorial trails under the heading Trails Covering the Basics.
7. Uninstalling the Java 2 SDK
If you should ever want to uninstall the Java 2 SDK, use the "Add/Remove Programs" utility in the Microsoft Windows Control Panel. As an alternative method, if you still have the original installation program that you used to install the Java 2 SDK, you can double click on it to launch an uninstall program.
If you use the Invocation API to launch an application directly rather than using the Java application launcher, be sure to use the correct paths to invoke the Java HotSpot Client Virtual Machine (VM) or Java HotSpot Server VM, as desired. The path within the Java SDK to the Java HotSpot Client VM is:
jre/bin/client/jvm.dll(on x86)
The path to the Java HotSpot Server VM is:

jre/bin/server/jvm.dll (on x86)

jre/bin/server/jvm.dll (on IA64)
The corresponding locations in the Java 2 Runtime Environment begin with j2re1.4.2 instead of jre. The Exact VM and Classic VM are no longer part of the Java 2 SDK, and existing code that uses the Invocation API to launch an application based on old paths to the Exact or Classic VMs will not work.

Troubleshooting the Installation

Below are some tips for working around problems that are sometimes seen during or following an installation. For more troubleshooting information, see the Java FAQ.
  • If Netscape 6.2.x fails to launch a 1.4.2 applet and you installed 1.4.2 after you installed 1.4 (and both are still installed), do either of the following:

    1. Uninstall 1.4 before you install 1.4.2;
    2. Before you install 1.4.2, open the 1.4 Java Plug-in Control Panel, select the Browser tab, and deselect Netscape 6.
  • If you see the following error message about Microsoft Windows Installer 2.0:
    An error occured while downloading the file
    http://www.installengine.com/Msiengine20/instmsiw.exe.
    What would you like to do?
    When installing version 1.4.2 of Java 2 Runtime Environment or Java 2 SDK (using the default minimized download rather than the single executable), InstallShield requires Microsoft Windows Installer 2.0 to be on your machine; if it is not found (or an older version is found), then InstallShield automatically tries to download Microsoft Windows Installer 2.0. If your machine is not on the Internet or is behind an authenticated proxy, the installation will fail at that point. To proceed, simply use the Windows Offline Installer from the download page. Microsoft Windows Installer 2.0 is included in this download. Alternatively, you can manually download Microsoft Windows Installer 2.0 by going to microsoft.com and searching for "Windows Installer 2.0". Version 2.0 of Microsoft Windows Installer is included in Windows XP and Windows 2000 Service Pack 3, but not in earlier versions of Windows.

    • To see which version of Microsoft Windows Installer is installed, do the following:

      1. Locate the file MSI.DLL. (Usually located in C:\WINNT\SYSTEM32 )
      2. Select the file and right-click on it.
      3. Choose "Properties" and click on the "Version" tab.

  • If you get an error about one of the following during InstallShield setup:
      1. Error extracting support files. A typical error message is An Installation support file could not be installed. The filename, directory or volume label syntax is incorrect.
      2. Error installing Ikernel.exe (0x any number)
      3. Access is denied
      4. Error loading Type Library/DLL
    These errors could be caused by a known problem with InstallShield. See the InstallShield web site for a discussion of this problem with possible solutions: http://support.installshield.com/kb/view.asp?pcode=ALL&articleid=Q1049
If you see the following error message:
The InstallShield engine (iKernel.exe) could not be launched.
Error loading type library/DLL
This message probably indicates that system file Stdole32.tlb is missing from your computer. You can obtain this file from the Microsoft web site. For Microsoft Windows 98 platforms, for example, this file is included in the DCOM98 product.
  • If you see the following error message on Microsoft Windows 2000
    config.nt. The system file is not suitable for running MS-DOS
    and Microsoft Windows Application
  • it indicates a problem with the %SystemRoot%\System32\COMMAND.COM file that has been seen on some installations of Microsoft Windows 2000. If you encounter this error message when you try to launch the installer, consult the Microsoft web site at: http://support.microsoft.com/support/kb/articles/Q142/2/71.asp

    for information about resolving the problem.
    If you see the following error message
    corrupt cabinet fil, then the file you have downloaded is corrupted. (A cabinet file contains compressed application, data, resource and DLL files.) Check its file size against the expected file size listed in these instructions. If they don't match, try downloading the bundle again.
    If you see the following error message
    System Error during Decompression, then you might not have enough space on the disk that contains your TEMP directory.
    If you see the following error message
    This program cannot be run in DOS mode, then do the following:
      1. Open the MS-DOS shell or Command Prompt window
      2. Right-click on the title bar
      3. Select Properties
      4. Choose the Program tab
      5. Push the Advanced button
      6. Make sure the item "Prevent MS-DOS-based programs from detecting Windows" is unchecked
      7. Select OK
      8. Select OK again
      9. Exit the MS-DOS shell
      10. Restart your computer.
    Private vs. public J2RE - Installing the Java 2 SDK installs a private Java 2 Runtime Environment and optionally a public copy. The private J2RE is required to run the tools included with the Java 2 SDK. It has no registry settings and is contained entirely in a jre directory (typically at C:\Program Files\j2sdk1.4.2\jre) whose location is known only to the SDK. On the other hand, the public J2RE can be used by other Java applications, is contained outside the SDK (typically at C:\Program Files\Java\j2re1.4.2), is registered with the Windows registry (at HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft), can be removed using Add/Remove Programs, might or might not be registered with browsers, and might or might not have java.exe copied to the Windows system directory (making it the default system Java platform or not).
    • Creating source files in Notepad - In Microsoft Windows, when you create a new file in Microsoft Notepad and then save it for the first time, Notepad normally adds the .txt extension to the filename. Therefore, a file you name Test.java is saved as Test.java.txt. It's important to note that you cannot see the .txt extension unless you turn on the viewing of file extensions (in Microsoft Windows Explorer, uncheck "Hide file extensions for known file types" under Folder Options). To prevent the .txt extension, enclose the filename in quotation marks, such as "Test.java", when typing it into the Save As dialog box.

    • On the other hand, Microsoft WordPad does not add a file extension if you provide one -- you must save the file as "Text Document".
      Choosing an installation path containing characters that are not part of the system code page - On Windows 2000, XP, and 2003, it is possible to name directories using characters that are not part of the system locale's code page. If such a directory is part of the installation path, then error 1722 occurs, and installation is not completed.
    • To prevent this problem, make sure that the user and system locales are identical, and that the installation path only contains characters that are part of the system locale's code page. User and system locales can be set in the Regional Options or Regional Settings control panel