Saturday, December 27, 2008
how to create user defined Objects in Javascript
How to retrieve System Properties in Java
The primary method which actually retrieves the property is System.getProperty(), and it takes key info as a parameter.
For details of all the System Properties and how it can be retrieved, you can visit my earlier post about How to retrieve System Properties through Java. You can generate the XML file of all the key-value pair of the properties and then you can use any if the key's from the XML file, in the below program to get the info in Java Code.
RetrieveSystemProperties.java
----------------------------
public class RetrieveSystemProperties
{
/*
File : RetrieveSystemProperties.java
Purpose: Retrieves and displays the System Property details
Author : Anaparthi Subrahmanyam
Published: 2008-12-27
Usage Notification: Author doesnt own responsibility of any loss of data,
responsibility for misuse or loss of any nature if this code is used. If possible,
please provide link to this webpage
*/
public static void main(String[] args)
{
try
{
/*
the below functions will retrieve the System Properties of the System
*/
// retrieving Operating System Name of the machine
System.out.println("Operating System Info: "+System.getProperty ("os.name"));
// retrieving Unicode Encoding
System.out.println("Unicode Encoding Info: "+System.getProperty ("sun.io.unicode.encoding"));
// retrieving User Language
System.out.println("Operating System Info: "+System.getProperty ("user.language"));
// retrieving Operating System Name of the machine
System.out.println("User Language Info: "+System.getProperty ("sun.management.compiler"));
// retrieving Desktop Information
System.out.println("Desktop Info: "+System.getProperty ("sun.desktop"));
// retrieving Sun Compiler name
System.out.println("Sun Compiler Info: "+System.getProperty ("sun.management.compiler"));
// retrieving Operating System patch level
System.out.println("Patch Info: "+System.getProperty ("sun.os.patch.level"));
// retrieving File encoding package
System.out.println("File encoding package Info: "+System.getProperty ("file.encoding.pkg"));
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
----------------------------
Please provide your comments, i will really appreciate it.
How do I retrieve the System Properties on Windows Machine using Java
Friday, December 26, 2008
Details about installing java on different Operating Systems
Sun Microsystems has provided a very nice page providing all the details about steps and links for How to Install Java and also provided links of different JDK’s for various operating systems.
Here is the Link : http://www.java.com/en/download/manual.jsp
How do i verify whether an URL is active or not through Java
Thursday, December 25, 2008
How do I pass numeric value as command line argument to Java
How do i pass command line arguments in Java
Wednesday, December 24, 2008
How to do I sum and print two numbers in Java Program
Tuesday, December 23, 2008
Storing java command output to text file.
The command is:
commandprompt>java GenerateLog >> UserFile.txt
here in the above example, java GenerateLog is the command to execute GenerateLog java file, and output will be dislayed on the console. But by providing the ">> UserFile.txt" at the end of it , the output will be directed to the file called UserFile.txt
By using the above command, a text file named UserFile will be stored in most probably c drive or in the current location
You can easily find this file.
Comment will be highly appreciated...
How do I configure User tools in editplus to compile and run java file
(Copy paste as it is)
First Java Program Example
Thursday, December 18, 2008
Example to setup first JMX MBean in WebSphere Application Server
Sharing with you all for your help, the link which provides details of setting up JMX with the examples.
http://www.ibm.com/developerworks/websphere/techjournal/0304_williamson/williamson.html
How to set Java Path to run Java Program
Please read my earlier post about How to install Java before setting the Java Path to compile java file.
Once you are done with Java Installation,Right click on the My Computer Icon of your desktop or if you dont have My Computer icon on your desktop then right click on the My Computer in File Explorer.
-> Select the Properties Item
-> Select the Advanced Tab
-> Click Envirnment Variables Button
-> Find path under System Variable section, select it and click edit button
-> It will open a pop up window , append %Java Installation Dir%\bin (make sure that before adding this value, you are placing a semicolon (;) and then appending the value. Semi colon is used as a separator between two different location in the Path Variable.) at the end in the Value field.
Note : %Java Installation Dir% means the folder where you have installed the java,but the path you have given upto bin folder under installed folder as it contains javac.exe (java compiler) and java.exe (executs Java )
Save your changes.
How to verify:
1.Open a command prompt
2. type java -version and press enter
if you are able to see some text on command prompt as
java version "1.5.0_14"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_14-b03)
Java HotSpot(TM) Client VM (build 1.5.0_14-b03, mixed mode, sharing)
Means Java is installed properly and your pc environment path is set to compile and run a java program.
If you are unable to get the above mentioned text, please verify whether you set the Environment variable properly as well as check the location you provided.
I hope it will help you to understand how to set path in computer to run java program.
How to install Java on my machine
Before running any Java program you need to have the Java installed on your machine. Normally beginners gets confused with different terminologies used in Java such as jdk,j2se,jre,jvm etc..
JDK - Java Development Kit/ J2SE( Java 2 Standard Edition)
JRE - Java Runtime Envrionment
JVM - Java Virtual Machine
All the above three are different , but if you install JDK, you will get JRE and JVM, if you install JRE , you will get JVM by defualt.
I tried to clear the concept so that before installing it may be bit less troublesome while installing Java for the first time.
About installing.. If you are installing Java on your machine for the purpose of writing code then you have to install the Java Development kit (jdk) , latest version will be good.
You can download JDK(1.5) from this location :
http://java.sun.com/javase/downloads/index_jdk5.jsp
After downloading , just double click on the exe file, which you have downloaded .
It will ask for the location where to install the software( by default it takes C:\Program Files), its upto your choice where you want to install it.I normally install in a separate folder as some times during the path setup on my machine , i was forced to modify the folder name C:\Program FIles to C:\Progra~1 as due to space in the folder name, PC unable to find the installed location.
Thats it.. wait till the installation is complete.