Wednesday, November 11, 2009

SVN Repository Migration

Steps to Move SVN from on server to another:

1. Take dump of current SVN server.

svnadmin dump --incremental -r 6274 /svn > rev6274.svn_dump

2. Create Repository on new Server

svnadmin create TestSVN

3. Load dump to new Repository (path to svn)

svnadmin load /home/shailesh/svnrepo/TestSVN
< /app/Work/Projects/rev6274.svn_dump

4. Configure virtual host on apache in apache config file.
here convert square braces to triangular braces.
[Location ]
DAV svn
SVNPath /home/shailesh/svnrepo/TestSVN
AuthType Basic
AuthName "ShaileshRepo"
AuthUserFile /etc/subversion/passwd
[LimitExcept ]
Require valid-user
[ / LimitExcept ]
[ / Location ]

5. AuthUserFile is file for Username and password to access svn.

6. Create AuthUserFile and add username and password.(user1 is username)
It will prompt for password and username & pwd will be added to passwd file.

sudo htpasswd -cm /etc/subversion/passwd user1

7. To add more user use ( c option is for creating file)
sudo htpasswd -m /etc/subversion/passwd user2

8. Give read/write permissions to SVN folder.

9. Restart apache server.

sudo /etc/init.d/apache2 restart

Tuesday, May 12, 2009

How to release Tomcat port on Ubuntu

Many times i was facing problem of Out of Memory error for Tomcat while developing applications.
Sometimes IDE failed to stop tomcat. And if you try to start tomcat again on same port, you get error that "port is already in use". In such cases, below are steps to release Tomcat port to restart tomcat again on same port.

1. Find out which process is using Port using command
sudo netstat -lpn |grep :8080
You will get output like
tcp6 0 0 :::8080 :::* LISTEN 6749/java

2. Process Id 6749 is using port 8080.

3. Kill the process using command
kill 6749

Now you can again use port 8080 to run tomcat on this port.

Tuesday, March 31, 2009

Sample Android application using Netbeans on UBUNTU

Sample Android application using Netbeans on UBUNTU

Step 1. Download Android SDK from
http://developer.android.com/sdk/1.1_r1/index.html

Unzip distribution.

Step 2. Setting Netbeans plugin for Android :
You can get details installing plugin for Android at
http://kenai.com/projects/nbandroid/pages/Install

Step 3.
Netbeans menu
Tools -- Java Platform
Click Add Platform button
Select Google Android Open Handheld platform.
Set Android SDK directory as Platform folder. (downloaded and unzipped in step 1)
Click next and set name as "Android".
Click finish.

Step 4. Create new Android Project
File -- Project --
Android -- Android Application
Set project Name as HelloAndroid for example.
click finish

Step 5.
Open Source packages
org.me.helloandroid.MainActivity.java file.

there is oncreate method as follows
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
// ToDo add your GUI initialization code here
}

Change it by adding few lines of code to display "Hello Android".

@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
// ToDo add your GUI initialization code here
TextView tv = new TextView(this);
tv.setText("Hello, Android");
setContentView(tv);
}

Step 6.
Run Application.

You will get "Hello Android" text on Android Emulator screen.


If You get Following Exception while running application :
trouble processing:
invalid constant pool index 0000
...while parsing attributes[1]
...while parsing Code attribute at offset 0000013e
...while parsing attributes[0]
...while parsing methods[0]
...while parsing org/me/helloandroid/R$layout.class
...while processing org/me/helloandroid/R$layout.class


Check java -version on console and set it as java-6

Here are steps how to set this:
on console window type : sudo update-alternatives --config java

It will give installed versions and option to set java version.

If java 6 is not in list use following link to install and set as default version
https://help.ubuntu.com/community/Java

Wednesday, March 18, 2009

Sort Objects of ArrayList

We use ArrayList many times to store list of Objects.
How to Sort records of ArrayList of objects using Collections.sort method based on particular field.

Suppose we have Class Employee as :

public class Employee {

private String empName;
private String empDept;
private double salary;

public String getEmpDept() {
return empDept;
}
public void setEmpDept(String empDept) {
this.empDept = empDept;
}
public String getEmpName() {
return empName;
}
public void setEmpName(String empName) {
this.empName = empName;
}
public double getSalary() {
return salary;
}
public void setSalary(double salary) {
this.salary = salary;
}
}

main method to demonstrate sorting of ArrayList which contains few Employees.

eg:
public static void main(String[] args) {

ArrayList empList = new ArrayList();
Employee e1 = new Employee();
e1.setEmpName("Abcd");
e1.setEmpDept("ACCT");
Employee e2 = new Employee();
e2.setEmpName("Ssss");
e2.setEmpDept("HRD");
Employee e3 = new Employee();
e3.setEmpName("rrrr");
e3.setEmpDept("MKTG");
Employee e4 = new Employee();
e4.setEmpName("bbbb");
e4.setEmpDept("ACCT");
Employee e5 = new Employee();
e5.setEmpName("mmmm");
e5.setEmpDept("DEVP");
empList.add(e1);
empList.add(e2);
empList.add(e3);
empList.add(e4);
empList.add(e5);
System.out.println("Before Sorting:");
for (Employee employee : empList) {
System.out.println("Employee :"+employee.getEmpName());
}

Collections.sort(empList, new Comparator(){
public int compare(Object obj1, Object obj2) {
Employee emp1 = (Employee) obj1;
Employee emp2 = (Employee) obj2;
return emp1.getEmpName().compareToIgnoreCase(emp2.getEmpName());
}
});
System.out.println("");
System.out.println("After Sorting:");
for (Employee employee : empList) {
System.out.println("Employee :"+employee.getEmpName());
}

}

Output is:
Before Sorting:
Employee :Abcd
Employee :Ssss
Employee :rrrr
Employee :bbbb
Employee :mmmm

After Sorting:
Employee :Abcd
Employee :bbbb
Employee :mmmm
Employee :rrrr
Employee :Ssss

Saturday, March 7, 2009

Happy Birthday Ketu

Wish you many happy returns of the day dear K2.
Miss you.
Always keep Smiling.

Sunday, February 1, 2009

Job Switch - Problems

Many things happened in last two months. I got offer from Yash Technologies, Pune in November so i resigned from my company. 12th Dec was relieving date. I was suppose to join Yash on 20th Dec.After almost three years in Mumbai,
i was shifting to Pune, my home town. On 13th Dec I packed all my luggage and went to Andheri station to catch Local Train at around 12.30pm. I planned to catch Sinhgad Express from CST.
I got call from one of the person from Yash Tech. at 1.00pm telling me that my offer of Employment was canceled due to internal restructuring. I was because few of their projects got canceled and they are not in position to give me joining. They accepted their fault but it affected me.
I came home in evening and checked mails.
They had sent me one Regret mail to cancel joining.
I was jobless at that time because i had already been relieved and their was no point in joining there again.
On Sunday i met one of my friend and told him everything. He said that there is opening for Java in their company.
I forwarded him my Resume and gave interview on Tuesday i.e. 16th Dec. I got selected and Joined immediately from 18th Dec.
I have to compromise on package while joining and joined on almost same package which i was getting previously and i had no option to accept it.

I feel to write all these things here because no other person should go through situation which i faced.