Friday, September 16, 2011

how to delete newline character from table

How to delete new line character from mysql table? replace new line character from table
I was facing a small problem...I was uploading a textfile data to a mysql database...my line tarminator is '\n'. in my comma seprated textfile each recode is written in a new line that is newline character at the end of each line...when I upload the data using load data infile....systax with the last column new line character is also added....I wanted to remove newline character form the database....
here is the final solution for this:


update table set field=replace(replace(field, "\n", ""), '\r', '')

Thursday, September 15, 2011

JSP Beginner Life Cycle of JSP

JSP (JavaServer Pages) - what is it?

JSP is a technology which enables the generation of dynamic web contents for a typical web application by separating the user interface generation from the actual content generation. This separation helps the page designers and content developers to do their respective tasks without interfering with each other. JSP can also be extended by adding Custom Tag Libraries to it.

A JSP page is just like a HTML web page that contains (strictly speaking we should say 'that may contain' as a plain static HTML page can also be saved as with a .jsp extension to make it a JSP page, but that's seldom used) additional pieces of code responsible for dynamic content generation. This additional code can utilize many Java APIs including JavaBeans, JDBC, EJB, and RMI for building the dynamic content. HTML part of the JSP page provides the layout in which the dynamically generated content is displayed.

Life Cycle of JSP (JavaServer Pages)

A JSP page is first converted into a Servlet and then that Servlet gets compiled and executed like any other Servlet. The translation of a JSP page into the corresponding Servlet is done by the JSP Engine of the underlying Web Container. The entire life cycle of a typical JSP page can be summarized as the following phases:-
 

  • Translation - In this phase the JSP page is translated into the corresponding Servlet. This translated Servlet is different from a normal Servlet only in the sense that it implements the interface javax.servlet.jsp.HttpJspPage. Well... if you look at this interface closely, you'll easily notice that a translated JSP page implements this interface just to have the JSP specific features. This HttpJspPage is just a wrapper of the Servlet interface as HttpJspPage interface extends the JspPage interafce and the JspPage interface extends the javax.servlet.Servlet interface. Thus, we see that the translated Servlet also internally implements the javax.servlet.Servlet interface (otherwise we would not have called it a servlet). In addition it implements few more interfaces to support the JSP technology.
  • Compilation - Once the JSP page has been translated into the corresponding Servlet, the next obvious step is to compile that Servlet.
  • Loading & Instantiation - As is the case with any compiled class (.class file), this servlet class also needs to be loaded into the memory before being used. The default classloader of the Web Conatiner will loads this class. Once the class is loaded, an instance of this class gets created. JspPage interaface contains the jspInit() method, which is used by the JSP Engine to initialize the newly created instance. This jspInit() method is just like the init() method of the Servlet and it's called only once during the entire life cycle of a JSP/Servlet.
  • Servicing Requests - _jspService() is the method which is called every time the JSP is requested to serve a request. This method normally executes in a separate thread of execution (provided we have selected Single Thread Model for the JSP) and the main JSP thread keeps waiting for other incoming requests. Every time a request arrives, the main JSP thread spawns a new thread and passes the request (incoming request) and response (new) objects to the _jspService() method which gets executed in the newly spawned thread.
  • Unloading - jspDestroy() method is called (almost always by the Web Container... Read a related article on why a JSP/Servlet writer shouln't call this method explicitly - Calling destroy() from init() in a Servlet >>) before the Web Container unloads the JSP instance. We normally keep code responsible for resource-reclaimation or clean-up activities in this method. After the execution of the jspDestroy() method, the JSP instance is marked for the garbage collection and the occupied memory is eventually reclaimed.

Monday, August 29, 2011

How to take database backup in java code

How to take database backup script in java code? Here is the sample java code to take database backup. According to this program, first get the tables list of a database, then export data of each table into separate txt file and save in the folder
//now backuping database..//
	try
	{
		String saveUrl="D://DataBackupWizard//DATABASE//";
String DB = "";
String url = "";
String uName = "";
String pwd = "";

Connection con=null;
Statement stm=null;
ResultSet rs=null;

File f=new File(saveUrl+dNames);
if(!f.exists())//create folder to store all txt file
{
f.mkdir();
}
String full_url="jdbc:mysql://"+url+"/"+dNames+"?autoReconnect=true";
Class.forName(DB);
con = DriverManager.getConnection(full_url,uName,pwd);
stm = con.createStatement();
if(done<tbList.size())
{
String tblName=(String)tbList.get(done);

File ft=new File(saveUrl+dNames+"//"+tblName+".txt");
if(ft.exists())// delete file if already exists
{
ft.delete();				
}

String query="SELECT * INTO OUTFILE 'D://DataBackupWizard//DATABASE//"+dNames+"//"+tblName+".txt' FIELDS TERMINATED BY '\t' FROM "+tblName;
System.out.println(query);
stm.executeQuery(query);
}

stm.close();
con.close();
}
catch(Exception Ex)
{
System.out.println(Ex);
}

Wednesday, August 17, 2011

How to make new window open at maximum size


Here is the tips for 'how to make new window open in maximum size using JavaScript'.

Basically we can’t control to open new pop up in new window with maximum size of browser, because OS setting of end user control.
But we can set the size of window wile opening new window. Here is example to open new pop op window in full screen:

Open new pop up window in full screen:
window.open('newWin.html','NewWindow','fullscreen=yes');

Another option to open new pop up window with dynamic size

 <a href="http://birenj2ee.blogspot.com/" onclick="window.open(this.href, 'child', 'height=' + screen.height + ',width=' + screen.width + ',resizable=yes'); return false">BirenJ2ee</a>

Another example to open pop up window with specific width and height:

window.open('http://birenj2ee.blogspot.com/','NewWindow','width=1000px,height=550px,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes, resizable=yes');

Android Guide Setup Eclipse and the Android SDK

Android Guide,
Setup Eclipse and the Android SDK  for beginner

How-To Install Android SDK On Windows, Integrate Android in Eclipse
Installing the Android SDK
The latest Android SDK for Windows, Mac and Linux can always be obtained from the following URI:
http://code.google.com/android/download.html
It only needs to be downloaded and unzipped to your preferred hdd-location.
The Android Development Tools (ADT)
Android provides an Eclipse plugin called ‘ADT’ to make programming and debugging easier. The ADT provides easy access to the LogCat, the Android-Manifest/Resource-Editor, File, Thread, and Heap Control, incoming call/sms simulation, etc… – since SDK-version m5 all for multiple emulator instances at the same time.


Installing the Eclipse Plugin (ADT)
To download and install the ADT plugin, follow the steps Google provides to developers:
1.       Start Eclipse, then select Help > Software Updates > Find and Install....
2.       In the dialog that appears, select Search for new features to install and press Next.
3.       Press New Remote Site.
4.       In the resulting dialog box, enter a name for the remote site (e.g. Android Plugin) and enter this as its URL:
https://dl-ssl.google.com/android/eclipse/ Press OK.
5.       You should now see the new site added to the search list (and checked). Press Finish.
6.       In the subsequent Search Results dialog box, select the checkbox for Android Plugin > Developer Tools. This will check both features: "Android Developer Tools", and "Android Editors". The Android Editors feature is optional, but recommended. If you choose to install it, you need the WST plugin mentioned earlier in this page.
Now press Next.
7.       Read the license agreement and then select Accept terms of the license agreement, if appropriate. Press Next.
8.       Press Finish.
9.       The ADT plugin is not signed; you can accept the installation anyway by pressing Install All.
10.   Restart Eclipse.
11.   After restart, update your Eclipse preferences to point to the SDK directory:
i)        Select Window > Preferences... to open the Preferences panel. (Mac OS X: Eclipse > Preferences)
ii)       Select Android from the left panel.
iii)     For the SDK Location in the main panel, press Browse... and locate the SDK directory.
iv)     Press Apply, then OK.

Updating the ADT Plugin
Updating the ADT Plugin follows the standard procedure of upgrading a common Eclipse plugin:
1)      Select Help > Software Updates > Find and Install....
2)      Select Search for updates of the currently installed features and press Finish.
3)      If any update for ADT is available, select and install.

Pathways of Web-based or java project development for beginner

About J2EE/Java programming in Market. market value of Java/J2EE/Mobile programming

Being a experience software programmer specially in Advanced Java, I am just sharing my views which can help lots of beginner who want to build their carrier in Java platform.
Web Based programming is taking innumerous market in 21 century, now the world & information is just sort of one click from us. Most of the information is available in net. Remaining of the information is circulating. And why not?, internet is one of the best, cheapest and most popular medium to market/flow the information to target audience.
And Web-based application/programs/software makes it to possible in very low cost.
Java/J2EE technology in one of the most popular and used technology to build such software.  For lay man, dynamic websites are created in advance technology having very high security.
There are lots of question for beginner:
Is Java Programming is very difficult?
I say Yes and No.
Yes its difficult, if you don't take it serious, if you don't understand its concept, if you don't practice.
No, its not so difficult as you think, if you just understand the concept of OOPs, just have more practice, or if you have background knowledge of c/C++, it will be very easy.

So, if you could understand concept of OOPS, class/Object/Methods, Interfaces etc, it will be very easy.


What are the possibilities pathways with in java?
There are lots of pathways with in java.
But from abstract level, they are:
Desktop/Standalone application: Java based GUI that runs in individual machine. For this, plain java files are used. Wed-based application: Based on Client-Server architecture. JSP/Servets are used. Mobile/J2ME application: Now a days mobile programming is becoming most popular. Most of the phone support java & lots of free application can be found. So mobile/J2ME would be one of the hot.

How do I start?
Very important question, but for all above java programming, basic concept of JAVA programming is required. So you must learn java, like classes, objects, methods, interface a concept of OOPS. Once you become familiar with these things you can adapt any further pathway. Yes don't think that u can't change programming from desktop application to web-based. You can switch any time and it won't be any problem. Because all are based on java programming only.

Which is most popular in the market?
Yes, now a days desktop/standalone application are not much used, however we can't say its not important. In some case it’s very useful. But according to current scenario, web based technology is getting popular, all the information are getting shared on internet, thus Web-based programming is most popular in market. Along with that J2ME/mobile programming is also popular.

Saturday, August 13, 2011

Convert array to arraylist in java with example

Here is the simple example, how to convert arrays to ArrayList or List in java.

Object[] array = new Object[]{"12","23","34"};
java.util.List list = Arrays.asList(array);


Tuesday, July 26, 2011

CSS Opacity not working in IE

Many of the times CSS Opacity of filter property is working fine in Firefox but not working in Internet Explorer.
After doing lot of search, test and trial i found that nested style of css opacity never works, opacity property of parent is automatically inherited in IE, thought it can work in Firefox/Mozilla. To solve this problem, I made the div for which css opacity property is to be applied as  parent most tag. I copied the code to top of the file.
After doing this stuff, now its working very fine in almost all browser.

So remember: css opacity property never work in nested tag, it overrides by parent opacity, child div automatically inherit parent's  opacity property. So to make it workable, take out this div/tag from its parent & make this div/tag as separate tag or parent of all tag. You can just move this tag to top of the page.

Friday, July 15, 2011

Sorting an ArrayList that contains pojo class

Sorting of ArrayList containing our own Class/Objects in java, Sorting ArrayList that contains customizes java class/objects in java . How to sort Arraylist that contains our own class in java?
Here is the example of sorting  a list that contains java pojo class.
In below example, we have Employee class with attribute id, first name & last name.
We have another class that actually use the sort() method of Collections which has to implement Comparator() to sort pojo with its field.

Here is the Employee Class
public class Employee 
{
    int id;
    String firstName;
    String lastName;
    
    public Employee(int id,String firstName,String lastName)
    {
        this.id=id;
        this.firstName=firstName;
        this.lastName=lastName;
    }
    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
    public String getFirstName() {
        return firstName;
    }
    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }
    public String getLastName() {
        return lastName;
    }
    public void setLastName(String lastName) {
        this.lastName = lastName;
    }
}

Here is actual class that sort the list which contains Employee objects
 
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;


public class SortEmployeeList
{
    public static void main(String[] args) 
    {
        Employee emp1 = new Employee(1,"Dipen","Khadka");
        Employee emp2 = new Employee(2,"John","Rotela");
        Employee emp3 = new Employee(3,"Shark","Anderson");
        Employee emp4 = new Employee(4,"Suman","Bhatt");
        
        List<Employee> employeeList = new ArrayList<Employee>();
        employeeList.add(emp1);
        employeeList.add(emp2);
        employeeList.add(emp3);
        employeeList.add(emp4);
        
        //sort by First name
        Collections.sort(employeeList, new Comparator() {
            @Override
            public int compare(Object obj1, Object obj2) {
                Employee emp1 = (Employee)obj1;
                Employee emp2 = (Employee)obj2;
                return emp1.getFirstName().compareToIgnoreCase(emp2.getFirstName());
            }
        });
        //Now the employeeList is sorted based on first name
        
        
        //sort by Last name
        Collections.sort(employeeList, new Comparator() {
            @Override
            public int compare(Object obj1, Object obj2) {
                Employee emp1 = (Employee)obj1;
                Employee emp2 = (Employee)obj2;
                return emp1.getLastName().compareToIgnoreCase(emp2.getLastName());
            }
        });
        //Now the employeeList is sorted based on last name
    }
} 

Thursday, July 7, 2011

Skip or Excluding/Disabling jsp Validation in Eclipse

Many of the times Validation of jsp in each and every changes irritate and time consuming for developer.

To Skip or Excluding/Disabling jsp Validation in Eclipse, we can disable validation process as below:


Go to Preferences -> Validation Find the Validator you wish to change and select settings (not all of the validators have settings).


You can also exclude specific folder from validation in eclipse, you have to follow following steps to excluse folder validation:


  1. Right click project
  2. Select properties
  3. Select validation
  4. Check Enable Project specific settings
  5. Click XMl Validator settings
  6. Select Exclude Gruop
  7. Click Add rule
  8. Select Folder or File name
  9. Click Next
  10. Select files or folder which are not validated.
  11. Click Finish
  12. Click OK
  13. Click OK

Thanks.

project facet Java version 6.0 is not supported problem in eclipse IDE

The problem we can face is due to lower version of java being specified in your facet settings.
We get this problem when we try to run Web application/project in eclipse IDE  and try to run in apache tomcat server.

The solution of this problem is:
Goto project properties -> Select Project Facets -> Check the Java version, if it is other than java 5.0 then click on Add/Remove Project Facets. 
A new pop-up will open select "Facets Project" from the configurations dropdown.
Now you will see a Project Facet named "Java". select the checkbox and change the version to 5.0 and click finish.
Clean build your workspace. 



Now It should work.
Thanks.

Friday, June 10, 2011

Demo Login example in Spring 3

Sample of Login application in Spring 3 with Annotation, Spring Annotation Example
Spring 3 support very good approach of annotation, you don't need to define each and every controller in xml. We can directly define name of the controller in the controller. Annotation has been used to define url in the controller.
Here is the sample of  login application in spring 3.
Application Name: Spring 3
For login Sample, we required following files:
index.jsp
Welcome to Main Page
<a href="LoginForm.bp">Login</a> 

Spring3-servlet.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:p="http://www.springframework.org/schema/p"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-3.0.xsd">

    <context:component-scan
        base-package="com.bp.controller" />

    <bean id="viewResolver"
        class="org.springframework.web.servlet.view.UrlBasedViewResolver">
        <property name="viewClass"
            value="org.springframework.web.servlet.view.JstlView" />
        <property name="prefix" value="/WEB-INF/jsp/" />
        <property name="suffix" value=".jsp" />
    </bean>
</beans>


LoginForm.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
 pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>

Login Form

User Name:
Password:

LoginController.java
package com.bp.controller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.validation.Errors;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.bp.controller.domain.User;
 
@Controller
@RequestMapping("LoginForm.bp")//this mean all  url must be */User...
public class HelloWordController {
 
 
  @RequestMapping(method = RequestMethod.GET)
     public String showForm(Map model) 
  {
             User loginForm = new User();
             loginForm.setUsername("Biren");             
             model.put("loginForm", loginForm);
             return "LoginForm";
     }
  
  @RequestMapping(method = RequestMethod.POST)
     public String processForm(User loginForm, BindingResult result,Map model) 
  {
             String userName = "a";
             String password = "a";
             if (result.hasErrors()) {
                     return "LoginForm";
             }
             System.out.println(loginForm.getUsername());
           //  loginForm = (User) model.get("loginForm");
             System.out.println(loginForm.getUsername());
             if (!loginForm.getUsername().equals(userName)
                             || !loginForm.getPassword().equals(password)) {
              
             
              model.put("loginForm", loginForm);
                     return "LoginForm";
             }
             model.put("loginForm", loginForm);
             return "LoginSuccess";
     }
 
}

User.java
package com.bp.controller.domain;


public class User {

 String username;
 String password;
 public String getPassword() {
  return password;
 }
 public void setPassword(String password) {
  this.password = password;
 }
 public String getUsername() {
  return username;
 }
 public void setUsername(String username) {
  this.username = username;
 }
 
}

Thursday, June 9, 2011

How to solve Address or Port already in use error in tomcat java


Tomcat startup failed: Address already in use: JVM_Bind
java.net.BindException: Address already in use:8080


If you are getting this exception & Tomcat server in not running, it mean tomcat server is already running in your computer using port 8080. You can check it from command prompt by typing netstat -an. To solve this problem, shut down your tomcat server 2-3 times an wait for few min (1-2 minutes). Then again start you tomcat server.

Wednesday, June 8, 2011

How to convert exponential value to normal decimal form in jsp/java

Problem to display double/large value in jsp/java? How to convert exponential value to normal decimal form in jsp/java?
Many of the time, when we try to display large decimal value in jsp, it display in the value in exponential form instead of normal.

Example: double value 11588200.0, but jsp display 1.15882E7
To display this value in normal decimal format, we can have small parser method separately or just format  as below
               DecimalFormat fmt = new DecimalFormat(value);
       String finalValue = fmt.format(d);


Now finalValue variable will have  11588200.00 value

Saturday, June 4, 2011

How to solve java.lang.ClassCastException?

java.lang.ClassCastException at...
You might get full exception stack trace of ClassCasteException. Before solving this problem we must know following information.

What is java.lang.ClassCastException ? Why do I get java.lang.ClassCastException?
This exception indicate that the code has attempted to cast an object to a subclass of which it is not an instance. For example, the following code generates a ClassCastException:
Object x = new Integer(0);
System.out.println((String)x);

Another example is, suppose you have set ArrayList into the request Object in Action, and you are retrieving Map object as below:
List a = new ArrayList();a.add("Biren");
request.setAttribute("data",a); //in servlet/action you set object of List
Map data = (Map)request.getAttribute("data"); // in jsp, you tried to store List object into Map object.
 or, here in jsp, you are trying to get date which is list type  and assign to map object.

So, to solve this problem, you must go through the code and find what kind of object you are setting, and store the object into same type.
If you are using Java 5, you can define type of object while creating object.
example:
List info = new ArrayList();
If you try to store int value into info, it will give you error at compile time,



Example:
In Servlet/Action
  
List a = new ArrayList();a.add("Biren");
request.setAttribute("data",a); //in servlet/action you set object of List

Class Cast Exception in jsp/other class:
Map data = (Map)request.getAttribute("data");

Correct approach:
 List a =(List)request.getAttribute("data");






Exception in thread main java.lang.OutOfMemoryError: Java heap space in tomcat

How to solve java.lang.out of memory error? Why do I get  java.lang.out of memory error? "Exception in thread "main" java.lang.OutOfMemoryError: Java heap space"
While we develop web application in java and deploy into Apache Tomcat server, if we are playing with huge data then we might be getting java.lang.OutOfMemoryError most of time.
This is error, and can't be caught at development time, so at runtime we will get this error at any time when we try to create lots of variable more than available.
People might be thinking that their machine have memory of 2GB, then why are they getting memory error? You might have small confusion, if you have 2GB it does not mean you server is using whole 2GB ram for your application. By default Apache Tomcat use just 64K from whole memory of the system.

Then how to fix out of lang memory problem? How to increase heap size memory for tomcat server?
Here is the solution for java.lang.OutOfMemoryError Java heap space error:

1: Increase memory for apache tomcat server from the system:
Example to increase memory for tomcat server:
Go to tomcat main folder\bin, open catilina.bat file, add following line to set minimum 128 M to maximum 256 M
set CATALINA_OPTS=-Xms128M -Xmx256M -Djava.awt.headless=true

2: Refractor code and use StringBuilder instead of String.
Basically, writing lots of code in same method is not good practice. Declaring lots of String variables and appending text to same String variable use much more memory.
As we know when we append any text to same String variable, it actually create new variable in memory, you can look into the String documentation. So if you use StringBuilder, it won't create new variable when you append text to same variable, it append text to same variable in the memory instead.





Friday, June 3, 2011

Content Management System, CMS List in java

Now a days, Java Content Management System makes life easier for developer who want to develop software with dynamic content. You can find list of JAVA CMS List.
List of  CMS in Java:
InfoGlue
This is another scabable, robust and advanced content management System
or portal platform.
OpenCms Project
This  is a high level (professional) Open Source Website Content
Management System based on XML and Java technology.
Enonic
This is flexible prttal framework that provides a powerful solution to
efficiently produce, maintain and publish content for Intranet ,
Internet and Extranet.
Ivata op 
This is a free Groupware/Exchange/Intranet system that have web front
end
Xitex WebContent M1
Enterprise content management solution Xitex WebContent M1,
which allows easy website management by any one who are non technical.
CuppaWeb CMS
This content management system is based in j2ee, java, WebStart and XML
technology.
Simplicis Marketing Dashboard
Asbru
Dot CMS
Alfresco
Magnolia
Hippo CMS
VosaoCMS
Yanel
OpenWGA
jAPS
Liferay
DSpace
Fedora
LogicalDOC
Nuxeo EP

Thursday, June 2, 2011

List of IDE for Java Development

Here are the list of useful IDE to develop java based project. These IDE are not serially, but all have some special advantage.

List of Java IDE, Java/J2EE IDE Lists, List of IDE for Java Development:

1. Eclipse

Eclipse very good and open source IDE for Java project development. It is used a lot commercially and personally. It was made in Java so it's cross-platform.
Lots of support for additional plug-ins  are available to extend
your developing needs.

2. IntelliJ Idea

This is an intelligent Java IDE intensely focused on developer productivity
which provides a robust combination of enhanced development tools.

3. Netbeans

Netbeans is another very good IDE. Netbeans has a built-in GUI Builder for those you like that R.A.D. It was made in Java so it's cross-platform like Eclipse.
This is best for Desktop based project that allows drag and drop option
to create form, textbox etc

4. JCreator

This is very good and very easy to use. This IDE was made in C++ unlike the ones above, which were all made in Java.
and it runs only in Windows platform.

5. DrJava

This IDE is a lightweight development environment for writing Java
project. DR. Java  is designed primarily for students, providing an
intuitive interface and the ability to interactively evaluate Java code.

6. BlueJ

BlueJ IDE developed towards first time Java developers.This IDE teaches
us lot of programming concepts in Java and  it also has a good UML tool.

7. Borland JBuilder

Borland JBuilder is a great commercial IDE for Java project. Some developers believe it's worth it
to pay its price. JBuuildet has a built-in Java GUI Builder too

Which programming language is best to develop software between java and .net?

What programming should I select for developing any software? Which programming language is best to develop software between java and .net? How do you choose the right programming language for your project?
There are lot of programming language that are used to create software from desktop application to web based. Java programming language and .Net are most popular programming language that is used world wide. Php is another popular one.  But lots of developer might want to know the difference between Java and .Net programming language. Basically both have language have some strong and weak points. Most of the programmer might want to know which language is to be used while developing any software.
 I would say, that depends on the requirements, available resource, technology and etc. Suppose, if your application should be platform independent, that should be installed in Linux, Solaris etc, then Java is best option.
Lets have some question.
What kind of skilled resources do you have?
What is the development environemnt?
Where do you want to host the software? Linux or Windows?
Is client is ready to pay software license?
How much time do you have to develop the software?
etc...

First option is you should choose the technology on which your resource are expert. If you have resource of Java skilled then its risky to choose .Net.

Development environment is also another important things to be noted, if you have to use Linux OS to develop then you must use Java.

Hosting environment is another important points that is to be remember, you cant host/deploy .Net based software in Linix or Solaris etc. Php/Java can be deployed.

Cost is another most factor. If you don't have budget, all the software for java development is free. For dot Net you must purchase paid version.

For time, I guess developing in .Net is faster than Java, because .Net provide drag and drop GUI.


Please fell free to add additional information.







Java Vs Dot .Net feature Comparison

Difference between Java and Dot Net, Java Vs Dot Net 
Which is better, Java or dot Net?
Java programming language and .Net are the most used technology world wide to developer any desktop and web based software. Both technology have own advantage and disadvantage.

.Net is product of Microsoft and Java is that of SUN Micro systems
So lets compare the JAVA and .Net feature wise,
JAVA .Net
Java is Programming Language Its not programming language, its framework
Platform dependency Platform Independent Dependent, run in any Windows only
Cost Free Required paid License
GUI Swing GUI User Friendly than Java
Developed By SUN Microsoft
IDE JBuilder, Eclipse, NetBeans etc Visual Studio

Wednesday, May 25, 2011

C++ Vs JAVA feature Comparision

Difference between C++ and Java, C++ Vs JAVA
To find the differences between C++ and Java programming languages we must know the goals for designing them.
Basically, C++ was designed for systems and applications programming, extending the C programming language.
Whereas, Java was created initially as an interpreter for printing systems but grew to support network computing.
So lets compare the C++ and JAVA feature wise,

C++ JAVA
Except for a few corner cases its
compatible with C source code.
No backward compatibility with any
previous language. Although the syntax is strongly influenced by C/C++,
but not compatible with C.
Platform dependent Platform independent, write once, run
everywhere.
Allows generic programming, procedural
programming and object-oriented programming
Encourages OOPS concept, object
oriented programming paradigm.
Its allows direct calls to native system
libraries.
Call through the Java Native Interface and
recently Java Native Access.
Exposes low-level system facilities. Runs in a protected virtual machine.
Only type names and object types are
provided
Allow meta programming and dynamic code
generation at runtime.
Has multiple binary compatibility
standards (commonly Microsoft and Itanium/GNU)
Has a binary compatibility standard,
allowing runtime check of correctness of libraries.
Support Pointers, References and pass by
value
Here, Primitive and reference data types
always passed by value only
Memory management explicitly, however
third party frameworks exist to provide garbage collection and supports
destructors.
Here, automatic garbage collection also
can be triggered manually. Java doesn't have concept of Destructor,
finalize() can be used but not recommended.
Supports struct, class and union, then it
can allocate them on stack or heap
Java supports only class and allocates
them on the heap. However Java 6 optimizes with escape analysis to
allocate some objects on the stack.
Allows overriding type explicitly Rigid type safety except for widening
conversions. Autoboxing/Unboxing added in Java 1.5.
Support operator overloading for most
operators.
The meaning of operators is generally
immutable, however the + and += operators have been overloaded for
Strings.
Support full multiple inheritance,
including virtual inheritance.
Only one inheritance from classes,
interfaces support multiple inheritance
Don't have standard inline documentation
mechanism. However  3rd party software like  Doxygen exists.
Provide Javadoc standard documentation.
Provide const keyword to define immutable
variables and member functions that do not change the object
Provide 'final' which is a limited version
of const, equivalent to type* const pointers for objects and plain const
of primitive types only. No const member functions, nor any equivalent
to const type* pointers.
Supports the goto statement. Supports labels with loops and statement
blocks.

Tuesday, May 24, 2011

Comparision between JSP/Servlet,Struts and Spring framework

Here is the comparision between JSP/Servlet,Struts and Spring framework. This difference is explained in the terms of View (JSP),Controller (Action) , Model & Configuration File.

Platform
View
Controller
Model
Configuration Files
JSP and Servlet
JSP
Extends HttpServlet
doPost()
doGet()
POJO
web.xml
Struts
JSP
Extends ActionSupport
Init()
Execute()
Validate()
Input()
POJO
web.xml
struts.xml
Spring
JSP
Extends Controller
handleRequest()
POJO
web.xml
*-servlet.xml
(applicationContext.xml)
Struts and Spring
Integration
JSP
Extends ActionSupport
POJO
web.xml
struts.xml
applicationContext.xml