Java

Java is a set of computer software and specifications developed by Sun Microsystems, which was later acquired by the Oracle Corporation, that provides a system for developing application software and deploying it in a cross-platform computing environment. Java is used in a wide variety of computing platforms from embedded devices and mobile phones to enterprise servers and supercomputers.

Spring Logo

Spring Framework

The Spring Framework provides a comprehensive programming and configuration model for modern Java-based enterprise applications - on any kind of deployment platform. A key element of Spring is infrastructural support at the application level: Spring focuses on the "plumbing" of enterprise applications so that teams can focus on application-level business logic, without unnecessary ties to specific deployment environments.

Hibernate Logo

Hibernate Framework

Hibernate ORM is an object-relational mapping framework for the Java language. It provides a framework for mapping an object-oriented domain model to a relational database.

Sunday, May 19, 2013

How to Install Sun Java JDK6 On Fedora 17/18

                                        How To Install Sun Java JDK6 On Fedora17/18


installing java on linux


The following are the steps to install a Sun JDK6 in Fedora. 

Step-1: Download the Java Jdk6 from the below link:
Download. 

After downloading you can get the rpm file( for example jdk-6u35-linux-x64-rpm.bin )

Step-2: Open terminal and copy the above file into any location. I am copying the above rpm file into following location
[ranga@ranga java]$ pwd
/home/ranga/install/java


[ranga@ranga java]$ ./jdk-6u35-linux-x64-rpm.bin
bash: ./jdk-6u35-linux-x64-rpm.bin: Permission denied
The above error you can get because of there is no permission to execute the above rpm file.
[ranga@ranga java]# chmod +x jdk-6u35-linux-x64-rpm.bin
Change to root user by using su command
[ranga@ranga java]$ su
Password:
[root@ranga java]# chmod +x jdk-6u35-linux-x64-rpm.bin
[root@ranga java]# ./jdk-6u35-linux-x64-rpm.bin
Unpacking...
Checksumming...
Extracting...
UnZipSFX 5.50 of 17 February 2002, by Info-ZIP (Zip-Bugs@lists.wku.edu).
  inflating: jdk-6u35-linux-amd64.rpm 
  inflating: sun-javadb-common-10.6.2-1.1.i386.rpm 
  inflating: sun-javadb-core-10.6.2-1.1.i386.rpm 
  inflating: sun-javadb-client-10.6.2-1.1.i386.rpm 
  inflating: sun-javadb-demo-10.6.2-1.1.i386.rpm 
  inflating: sun-javadb-docs-10.6.2-1.1.i386.rpm 
  inflating: sun-javadb-javadoc-10.6.2-1.1.i386.rpm 
Preparing...                ########################################### [100%]
   1:jdk                    ########################################### [100%]
Unpacking JAR files...
 rt.jar...
 jsse.jar...
 charsets.jar...
 tools.jar...
 localedata.jar...
 plugin.jar...
 javaws.jar...
 deploy.jar...
Installing JavaDB
Preparing...                ########################################### [100%]
   1:sun-javadb-common      ########################################### [ 17%]
   2:sun-javadb-core        ########################################### [ 33%]
   3:sun-javadb-client      ########################################### [ 50%]
   4:sun-javadb-demo        ########################################### [ 67%]
   5:sun-javadb-docs        ########################################### [ 83%]
   6:sun-javadb-javadoc     ########################################### [100%]

Java(TM) SE Development Kit 6 successfully installed.

Product Registration is FREE and includes many benefits:
* Notification of new versions, patches, and updates
* Special offers on Oracle products, services and training
* Access to early releases and documentation

Product and system data will be collected. If your configuration
supports a browser, the JDK Product Registration form will
be presented. If you do not register, none of this information
will be saved. You may also register your JDK later by
opening the register.html file (located in the JDK installation
directory) in a browser.

For more information on what data Registration collects and
how it is managed and used, see:
http://java.sun.com/javase/registration/JDKRegistrationPrivacy.html

Press Enter to continue.....

Done.
[root@ranga java]# 


Now your installation is complete.

Step-3: Now you need to set the environment variables
There are two ways to set environment variables to the user wise.
1. Only particular user by using .bash_profile
2. Set to common to all users by using .profile
I am setting the the path to only particular user by using .bash_profile
Go to your home directory
 

[root@ranga java]$ cd
[root@ranga java]$ pwd
/home/ranga
[root@ranga ~]$ vi .bash_profile 
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

PATH=$PATH:$HOME/.local/bin:$HOME/bin
#export PATH

JAVA_HOME="/usr/java/jdk1.6.0_35"
export JAVA_HOME

export PATH=${JAVA_HOME}/bin:${PATH}
unset USERNAME

[root@ranga~]$. .bash_profile
Now check the JAVA_HOME setted properly or not by using following command.
 

[root@ranga~]$ echo $JAVA_HOME
/usr/java/jdk1.6.0_35
 

Step-4: Removing Open JDK

[root@ranga jdk1.6.0_35]# rpm -qa | grep java 

sun-javadb-core-10.6.2-1.1.i386 
sun-javadb-docs-10.6.2-1.1.i386 
tzdata-java-2013b-2.fc17.noarch 
sun-javadb-client-10.6.2-1.1.i386 
sun-javadb-javadoc-10.6.2-1.1.i386 
sun-javadb-common-10.6.2-1.1.i386 
java-1.7.0-openjdk-1.7.0.19-2.3.9.1.fc17.x86_64 
sun-javadb-demo-10.6.2-1.1.i386 
[root@ranga jdk1.6.0_35]# rpm -e --nodeps java-1.7.0-openjdk-1.7.0.19-2.3.9.1.fc17.x86_64
[root@ranga jdk1.6.0_35]# rpm -qa | grep java
sun-javadb-core-10.6.2-1.1.i386
sun-javadb-docs-10.6.2-1.1.i386
tzdata-java-2013b-2.fc17.noarch
sun-javadb-client-10.6.2-1.1.i386
sun-javadb-javadoc-10.6.2-1.1.i386
sun-javadb-common-10.6.2-1.1.i386
sun-javadb-demo-10.6.2-1.1.i386

Final step is reboot your system. 

[root@ranga jdk1.6.0_35]# reboot
After rebooting check once again which java installed.
[ranga@ranga ~]$ which java
/usr/java/jdk1.6.0_35/bin/java
[ranga@ranga ~]$ java -version
java version "1.6.0_35"
Java(TM) SE Runtime Environment (build 1.6.0_35-b10)
Java HotSpot(TM) 64-Bit Server VM (build 20.10-b01, mixed mode)

Wednesday, May 1, 2013

Username is not in the sudoers file. This incident will be reported


If you are not on the "sudoers" list yet, Fedora/Ubuntu will tell you. You will see output like this:



Only the users listed in /etc/sudoers have the permission to use the command "sudo".

To give the sudo permission to a user we need to add the user to the file /etc/sudoers file.






Open the terminal and give the read and write permision to the sudoers file

chmod u+rw /etc/sudoers




Add the line




Here ranga is  the username

under the User privilege specification section.
Save the file and exit, now the sudo command should work for the user which was added in the file.

Sunday, April 14, 2013

How to Install Oracle 11g XE on Linux Fedora 17/18


Installing Oracle Database 11g XE on Fedora 17/18

[Oracle 11g Logo]

The following are the steps to install a Oracle 11g in fedora.

Step1:  Downloading the Software

Download the oracle-xe-11.2.0-1.0.x86_64.rpm.zip file from follwing url

Step2: Extracting the content

Extract the zip into any location. Here i am extracting the above zip into following location.

[ranga@ranga Disk1]$ pwd

/home/ranga/install/Disk1
[ranga@ranga Disk1]$ ls
oracle-xe-11.2.0-1.0.x86_64.rpm  response  upgrade
[ranga@ranga Disk1]$ 

Step3: Install libaio

[root@ranga Disk1]#  yum install libaio

Step4: Installing the oracle by using rpm command.

[root@ranga Disk1]# rpm -i oracle-xe-11.2.0-1.0.x86_64.rpm
Preparing... ########################################### [100%] 1:oracle-xe ########################################### [100%] Executing post-install steps... You must run '/etc/init.d/oracle-xe configure' as the root user to configure the database.

Your installation done but u need configure

Step5: Configuring the database

[root@ranga Disk1]# /etc/init.d/oracle-xe configure

Oracle Database 11g Express Edition Configuration ------------------------------------------------- This will configure on-boot properties of Oracle Database 11g Express Edition. The following questions will determine whether the database should be starting upon system boot, the ports it will use, and the passwords that will be used for database accounts. Press <enter> to accept the defaults. Ctrl-C will abort. Specify the HTTP port that will be used for Oracle Application Express [8080]: 9090 Specify a port that will be used for the database listener [1521]: Specify a password to be used for database accounts. Note that the same password will be used for SYS and SYSTEM. Oracle recommends the use of different passwords for each database account. This can be done after initial configuration: Confirm the password: Do you want Oracle Database 11g Express Edition to be started on boot (y/n) [y]:y Starting Oracle Net Listener...Done Configuring database...Done Starting Oracle Database 11g Express Edition instance...Done Installation completed successfully.

In the above configuration, i am given port number is 9090 by default 8080 and database listener is same and you need to enter SYS or SYSTEM password. If you want while booting it self starting the database your giving 'y' in boot option. Finaly your database configured successfully. This installation created under /u01 directory. 

Starting the Database manually : 


To start the database manually, run this command as root user:
# /etc/init.d/oracle-xe start
or
# /usr/lib/oracle/xe/app/oracle/product/11.2.0/server/bin/lsnrctl start

Stopping the Database manually:
To stop the database manually, run the following command as root user:
# /etc/init.d/oracle-xe stop

Un Install the Oracle 11g: 

Step1: First you need to check which oracle version is installed.
[ranga@ranga ~]$ rpm -qa | grep oracle
oracle-xe-11.2.0-1.0.x86_64
Step2: Uninstall the oracle by using rpm -e with which version it is installed.
[ranga@ranga ~]$ rpm -e 
oracle-xe-11.2.0-1.0.x86_64

Thursday, March 28, 2013

Setting the Classpath in Intellij IDEA

Setting the Classpath in Intellij IDEA:
Way1 :
  1. Open Project Structure (either Ctrl+Alt+Shift+S or File > Project Structure)
  2. Select "Modules" on the far left under Project Settings
  3. Select the module in question in the middle pane
  4. Arrange the order of the dependencies lists. One of the dependencies will be <Module Source> Which ever is listed first will be the one IDEA will give preference to. So if you want the local instance of Foo to be used, make sure <Module Source> is above the dependency.
screenshot.png
Way2:
  1. Right click on any directory in your IntelliJ project, select "Mark Directory As...", and choose "Source Root". 
  2. That director folder will change color from yellow to blue; IntelliJ considers all those directories to be in your CLASSPATH.

Friday, December 28, 2012

Encode and Decode Example in Java

This post demonstrates the how to encode and decode the String data.

package com.ranga;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;

/**
* This class is used to encode and decode the string data.
* @author Ranga Reddy
* @version 1.0
*/

public class EncodeAndDecodeExample {
private static final String data = "Hello, I am Ranga Reddy. ";

public static void main(String[] args) {

String encodedData = getEncodedData(data);
System.out.println("Encoded Data: " + encodedData);

String decodedData = getDecondedData(encodedData);
System.out.println("Decoded Data: " + decodedData);
}

private static String getDecondedData(String encodedData) {
try {
return URLDecoder.decode(encodedData, "UTF-8");
} catch (UnsupportedEncodingException exception) {
throw new RuntimeException("Does not support UTF-8");
}
}

private static String getEncodedData(String data) {
try {
return URLEncoder.encode(data, "UTF-8");

} catch (UnsupportedEncodingException exception) {
throw new RuntimeException("Does not support UTF-8");
}
}
}

Output:
Encoded Data: Hello%2C+I+am+Ranga+Reddy.+
Decoded Data: Hello, I am Ranga Reddy.