Archive for category Start

Some of the System Properties of Java

If we want to programmatically determine what version of the Java Runtime Environment

(JRE) is being used to execute a given application then, we can get the version via the following code illustrates:

//IN WINDOWS PLATFORM

String ver = System.getProperty("java.version"));
System.out.println("This program is running under JRE version " + ver);</code>

if (ver.startsWith("1.5")) {
     // Pseudocode.
     do something appropriate for newer versions of Java ...
}

else {
     // Pseudocode.
    do something the pre-5.0 way ...
}

Some of the java System Properties based on JDK 1.5 are given as follows:


Key Description of Associated Value

java.version Java Runtime Environment version
java.vendor Java Runtime Environment vendor
java.vendor.url Java vendor URL
java.home Java installation directory
java.vm.specification.version Java Virtual Machine specification version
java.vm.specification.vendor Java Virtual Machine specification vendor
java.vm.specification.name Java Virtual Machine specification name
java.vm.version Java Virtual Machine implementation version
java.vm.vendor Java Virtual Machine implementation vendor
java.vm.name Java Virtual Machine implementation name
java.specification.version Java Runtime Environment specification version
java.specification.vendor Java Runtime Environment specification vendor
java.specification.name Java Runtime Environment specification name
java.class.version Java class format version number
java.class.path Java class path
java.library.path List of paths to search when loading libraries
java.io.tmpdir Default temporary file path
java.compiler Name of JIT compiler to use
java.ext.dirs Path of extension directory or directories
os.name Operating system name
os.arch Operating system architecture
os.version Operating system version
file.separator File separator (/ on Unix)
path.separator Path separator (: on Unix)
line.separator Line separator (\n on Unix)
user.name User’s account name
user.home User’s home directory
user.dir User’s current working directory

The following table describes some of the most important system properties BASED on JDK 1.6


Key Description of Associated Value

"file.separator" Character that separates components of a file path. This is
/” on UNIX and “\” on
Windows.
"java.class.path" Path used to find directories and JAR archives containing class files.
Elements of the class path are separated by a platform-specific character specified in the path.separator property.
"java.home" Installation directory for Java Runtime Environment (JRE)
"java.vendor" JRE vendor name
"java.vendor.url" JRE vender URL
"java.version" JRE version number
"line.separator" Sequence used by operating system to separate lines in
text files
"os.arch" Operating system architecture
"os.name" Operating system name
"os.version" Operating system version
"path.separator" Path separator character used in java.class.path
"user.dir" User working directory
"user.home" User home directory
"user.name" User account name

Tags: , , , ,

Java Software Development Kit Installation (Windows)

First of all if you have already java then uninstall that java and download Java Sdk from Sun Microsystem :
For download: jdk (Java Development Kit)
Then choose your appropriate Operation System and download and Install the *.EXE program

This is one of the tough point for beginner to install java Beginner.

Some of the steps to maintain Path of Java compiler are given as follows:

STEP 1: Right click on My Computer and Go properties.

STEP 2: Dialogue Box Appears (given in fig 1.1) Go to Advance Tab > Environment Variables..

Fig 1.1

Fig 1.1 A Dialogue Box of Advance Tab

STEP 3: Now in New Dialogue box (given in fig.1.2 ) You can click on New Tab for creating new variable Read the rest of this entry »

Tags: , , , , ,

Java’s Print similarities to C

As we know that java is made by the C programming. The java has many common features to C language. While we wants to print in java we usually use the following code.

System.out.println(statement1);
or
System.out.print(statement2);

But there is also the feature of printf in java which we used to do in C programming:

Syntax:

//In C language
printf("format_string", comma_separated_list_of_expressions);

//In JAVA
System.out.printf("format_string", separated_list_of_expressions);

For eg:

 
//In C we use
void main(){
int sum = 4;

printf("The sum is %d , sum);
}

which outputs like this in C :
c-out

But in Java Read the rest of this entry »

Tags: , , , ,

Temperature Convert

NOW IN THIS PART U WILL LEARN HOW TO CONVERT TEMPERATURE TO FAHRENHEIT OR VICE VERSA
[sourcecode=’java’]
public class Temperature {

public static double temp;
public static final double FAHRENHIET_FREEZ = 32.0;
public static final double FAHRENHIET_BOIL = 220.0;
public static final double CELCIUS_FREEZ = 0.0;
public static final double CELCIUS_BOIL = 100.0;

//client code
//now here you can input the value either of fahrenheit
//or celcius only (but only one);
public static double celcius;
public static double fahrenheit;

public static double fahrenheitToCel(){

return (fahrenheit-FAHRENHIET_FREEZ)*(5.0/9.0);
}

public static double celToFahrenheit(){

return celcius*(9.0/5.0) + FAHRENHIET_FREEZ;

}
public void display(){

if(this.fahrenheit > FAHRENHIET_FREEZ){
System.out.println(“The temperature is “+
this.fahrenheit +” Fahrenheit which is equal to ”
+ Temperature.fahrenheitToCel() +” celcius “);
}
else{
System.out.println(“The temperature is “+this.celcius
+” Celcius which is equal to ” +
Temperature.celToFahrenheit() +” Fahrenheit ” );
}

}

public static void main (String[] args) {

Temperature temp = new Temperature();
temp.display();

}

}
[/sourcecode]

Tags: , , ,

Interface Class

Actually Interface are just like a class where it consists only constants and they
We can extend interface via interfaces
We can implement the interface via classes.
In interface needn’t use the “public” or “abstract” keywords – all methods
declared by an interface are automatically public and abstract by default.
A simple example of interface implement is given below.
[sourcecode=’java’]
public interface testInterface {
//one of the method without method body
void disp(String text);
}[/sourcecode]
For implementing this interface through normal class we follow below step: Read the rest of this entry »

Tags: , , ,