Search This Blog

Wednesday 28 December 2011

Compiling The Java Program With environment variables

In WINDOWS 2000 you do not use AUTOEXEC.BAT file. Instead you create environment variables. On your computer desktop right click the My Computer icon and select Properties.

On the System Properties window select Advance tab.


On Windows 7 select Start, right click Computer. Click Advance System setting on System properties window select Advance tab, Click Environment Variables button
On Windows XP, to get to the same System Properties window, select Start, Select Control panel,
In the opened Control panel select Performance and Maintenance (it is ar the bottom),



Select System, Advance tab.



Click the Environmental Variables button. Environment Variables window displays.


Click New button in System variables frame at the bottom of the Environment Variables Window. For Java SDK enter Path environment variable and.


enter path to JAVA bin folder on your PC. On mine it is C:\j2sdk1.4.0\bin. Type semicolon at the end. If you installed tomcat after java type path to tomcat bin folder on your PC. On mine it is C:\j2sdk1.4.0\bin;C:\jakarta-tomcat-4.1.29\bin;. Do not forget to type semicolon. Click OK button. Click OK button on Environment Variables window. Click OK button on Properties window.
To execute Java program create CLASSPATH environment variable.




For Tomcat enter CATALINA_HOME environment variable name and path to the folder where your tomcat installed. On mine it is C:\jakarta-tomcat-4.1.29


To run Tomcat you need to create JAVA_HOME environment variable. To check your configuration for Tomcat go to C:\jakarta-tomcat-4.1.29\bin directory, type startup and press enter.


Tomcat starts in separate command prompt window.












If Tomcat does not start, probably you have not enough memory set in command prompt. Go to command prompt menu on your desktop and right click it

From drop down menu select properties. Select memory tab. Increase convention memory and click OK to save changes.


Close command prompt if you had it open. Open again and try to start Tomcat.
Now it should be started. To make sure that Tomcat is running properly, open Internet Explored and type URL address:
http://localhost:8080
Tomcat home page displays.



Java Objects with Example


Objects
Object-oriented programming focuses on constructs called “objects.” An object consists of data and functions known as methods which use or change the data. (Methods are similar to procedures or functions in other languages.)

 Objects of the same kind are said to have the same type or be in the same class. A class defines what data can be in an object, and what operations are performed by the methods. One or more objects can be created or “instantiated” from a class.

 The structure of a Java program consists of various objects exchanging messages. The keyword class defines a blueprint for objects with similar properties.

 In our first example we define the class Particle

public class Particle
{
   double x, y, vx, vy, mass;
}

This class does not do anything (because it has no methods), but it can be used to describe a particle by its position, velocity, and mass. For simplicity, we will consider only two dimensions.

What is Java?



  • A high-level programming language developed by Sun Microsystems. Java was originally called OAK, and was designed for handheld devices and set-top boxes. Oak was unsuccessful so in 1995 Sun changed the name to Java and modified the language to take advantage of the burgeoning World Wide Web.


  • Java is an object-oriented language similar to C++, but simplified to eliminate language features that cause common programming errors. Java source code files (files with a .java extension) are compiled into a format called bytecode (files with a .class extension), which can then be executed by a Java interpreter. Compiled Java code can run on most computers because Java interpreters and runtime environments, known as Java Virtual Machines (VMs), exist for most operating systems, including UNIX, the Macintosh OS, and Windows. Bytecode can also be converted directly into machine language instructions by a just-in-time compiler (JIT).

  • Java is a general purpose programming language with a number of features that make the language well suited for use on the World Wide Web. Small Java applications are called Java applets and can be downloaded from a Web server and run on your computer by a Java-compatible Web browser, such as Netscape Navigator or Microsoft Internet Explorer.