Showing posts with label Eclipse. Show all posts
Showing posts with label Eclipse. Show all posts

A Java Runtime Environment (JRE) or Java Development Kit (JDK) must be available in order to run Eclipse. No JVM was found after searching the following locations:

A Java Runtime Environment (JRE) or Java Development Kit (JDK) must be available in order to run Eclipse. No JVM was found after searching the following locations:
If you are facing this kind of issue while opening eclipse after installing JRE/JDK, below are a few fixes you can try out -

1. Set environment variable Path as below

  • Path=C:\Program Files\Java\jdkx.x.x_yy\bin (for 64 bit windows check in Program Files (x86) folder).

2. Another fix is
  • Right click on the Eclipse icon in your desktop.
  • Properties
  • Target: C:\eclipse\eclipse.exe -vm C:\Java\jdkx.x.x_yy\jre\bin\javaw.exe (for 64 bit windows check in Program Files (x86) folder).
3. Yet Another fix is 
  • In your eclipse.ini file you need to specify the path to the Jave executable.
  • -vm C:\Program Files\Java\jdkx.x.x_yy\bin\javaw.exe (for 64 bit windows check in Program Files (x86) folder).


How to install Eclipse 3.6 in Ubuntu OS.

How to install Eclipse 3.6 in Ubuntu OS.

It is a common requirement for Java development. By default we can install eclipse indigo from Ubuntu software center. But most of the times we need to install different version's of Eclipse IDE [aka eclipse Helios or eclipse Juno ..etc.] based on project requirements.

In this tutorial, briefly explaining about how to install eclipse Helios 3.6 in Ubuntu.

Prerequisites :

Once you done with Java installation. Then, you can follow the below instruction's to install eclipse in you Machine running with Ubuntu

Syntax:

tar -xvf eclipse-SDK-3.6.1-linux-gtk.tar.gz

Once tar command executes successfully, Then it creates eclipse folder.

Next step is move the eclipse folder in to the root directory. To do this follow the given steps.

sudo mv eclipse /opt/

Enable the file and Folder permissions :

sudo chmod -R +r /opt/eclipse
sudo chmod +x /opt/eclipse/eclipse

Create an executable in your path:

sudo touch /usr/bin/eclipse
sudo chmod 755 /usr/bin/eclipse
sudo gedit /usr/bin/eclipse

Copy the following content and paste it into eclipse file and save it:

#!/bin/sh
export ECLIPSE_HOME="/opt/eclipse"
$ECLIPSE_HOME/eclipse $*

Now, It's time to create a symlink to execute/ run eclipse everywhere.

sudo ln -s /usr/bin/eclipse /bin/eclipse

Finally, we need to create the menu icon:

sudo gedit /usr/share/applications/eclipse.desktop

Copy and paste the below content in to eclipse.desktop file and save it:

[Desktop Entry]
Encoding=UTF-8
Name=Eclipse
Comment=Eclipse IDE
Exec=eclipse
Icon=/opt/eclipse/icon.xpm
Terminal=false
Type=Application
Categories=GNOME;Application;Development;
StartupNotify=true

Now everything is done. It's time to run eclipse [ aka. first time]:

eclipse -clean
In Ubuntu you can also launch the eclipse using GNOME menu Applications -> Programming -> Eclipse.

How to sort contents in ArrayList using Comparator

How to sort contents in ArrayList using Comparator
Mostly, we come with the requirement to generate reports based input. If you are retreiving data from Database it easy to sort and generate required output. But If your objects alread add in to list how do sort the content based on input value.


Requirement : I have a Person class with the fields Name and Age. My requirement is I would like generate report to list out Person Details with sort functionalities based on input [ like name or age ].


Person.java
package com.becbe.personal;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
 
public class Person {
    public String age;
    public String name;
    
    public String getAge() {
        return age;
    }
    public void setAge(String age) {
        this.age = age;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    
    public static Comparator<Person> getComparator(final String sortBy)
    {
        if("name".equals(sortBy)){
        return new Comparator<Person>() {
            
            public int compare(Person o1, Person o2) {
                
                return o1.getName().compareTo(o2.getName());
            }
         };
        }
        else if("age".equals(sortBy))
        {
            return new Comparator<Person>() {
                
                public int compare(Person o1, Person o2) {
                    
                    return o1.getAge().compareTo(o2.getAge());
                }
             };
        
        }
        else {
            throw new IllegalArgumentException("invalid sort field '" + sortBy + "'");
          }
    }
       
    public static void main(String s[])
    {
        List<Person> personSummary=new ArrayList<Person>();
        
        Person person1=new Person();
        person1.setAge("25");
        person1.setName("Thulasiram.P");
 
        Person person2=new Person();
        person2.setAge("15");
        person2.setName("wrangler");
    
        Person person3=new Person();
        person3.setAge("29");
        person3.setName("Alex");
        
        personSummary.add(person1);
        personSummary.add(person2);
        personSummary.add(person3);
        
        
        Collections.sort(personSummary,Person.getComparator("age"));
        
        for(Person p : personSummary)
        {
            System.out.println("Name :" + p.getName() + " Age :" +p.getAge());
        }
    } 
}

out put:
Name :wrangler Age :15

Name :Thulasiram.P Age :25

Name :Alex Age :29

Eclipse set up for GWT application development


In this post, I explain about the eclipse setup for GWT and Smart GWT application development.
Prerequisites:
·        Download eclipse[eclipse-jee-galileo]
·        Install GWT plug-in for eclipse
Steps to install GWT plug-in for eclipse:

1.      Open eclipse IDE. Click on Help Ã Install New Software
         
2.      Install GWT eclipse plug-in by click on add button and add Site with the following information.



 
1.      Install GWT eclipse plug-in by click on add button and add Site with the following information.

Name : Eclipse 3.5 (Galileo)

Name: Eclipse 3.7 (Indigo)
Location: http://dl.google.com/eclipse/plugin/3.7

Name: Eclipse 3.6 (Helios)
Location:  http://dl.google.com/eclipse/plugin/3.6

·        Click OK button.
·        Enable the following list of check boxes is shown in the following figure.


Note:  GWT Designer for GPE is optional, if you are familiar to use GWT designer tool to draw GWT components we can enable check box, otherwise it's not required.
click Next.
Click Next, accept the License and click Finish.
Now eclipse IDE environment setup is completed to develop GWT applications. In the Next post we discus about how to create GWT application.

Eclipse plugin for Hibernate2.x application development

Eclipse plugin for Hibernate2.x application development

Hibernate provides an Eclipse to common Hibernate tasks such as Creating / Updating a Database Schema, running Hibernate queries and creating simple Hibernate Mapping documents

Note this plugin will only work with Eclipse 2 (WSAD 5) and above. Queries and Schema features are Hibernate2 only
Installation:

Unzip hibernator-0.9.x.zip into /plugins
If you downloaded hibernator-0.9.x-nolibs.zip then you will need to add the following .jars that come with Hibernate - xml-apis.jar - commons-beanutils.jar - commons-collections.jar - commons-lang.jar - commons-logging.jar - dom4j.jar - hibernate2.jar - odmg.jar - cglib.jar
Restart Eclipse
Connecting to a Database:

Open Hibernate Perspective
Right click in connection view and select "Add"
Select one or more projects from the list (All *.hbm.xml documents in the selected projects are Configured into Hibernate)
Click next and enter the Database details (I will change this so you can select a hibernate.properties file instead)
Click finish
Click on the Hibernate Log View
Select and right click on the new connection. Click on "Connect!"
Confirm the mappings and connection are ok in the Log View - Simply hit "Connect!" on any other connections to prepare them for Query or Schema Update/Create
 Running a query:

Make sure you have created and connected to a database as above
Type your query into the "Query View" and hit "Execute"
Not the table of results in the "Results View" or any errors in the "Log View"
Updating / Creating Schema:

Make sure you have created and connected to a database as above
Click on Create or Update Schema in the "Query View"
Note the results in the "Log View"

 Creating a simple mapping document:

Go to menu Window->Show View->Other and select Hibernator
Open up some Java source and the plugin will either display the mapping file .hbm.xml or a generated version
To save the contents of the mapping file right click in the window and select "Save"

Download the latest (0.9) from - http://sourceforge.net/projects/hibernator
Report any bugs / Submit patches to - http://sourceforge.net/projects/hibernator 


Original code from

Christopher (Jozsa Kristof) dyn@on... (that's all the Sourceforge lists will show me)
Contributions from
Gavin King
Daniel Bradby

Steps to setup for database developement in Eclipse IDE


1. Select Windows->Open Prespective-->Other

 


2.Select the Database Driver for MySQL
 3. Select MySQL Database version
 

 4.Add mysql-connectorj.jar file.

 

 5. Provide Database Related In formations.

Steps to create UserLibrary in Eclipse IDE

User Library:
Normally if you develop any hibernate related applications we need to setup required jar files in to System class path. Suppose if we develop applications using IDE , we need to copy the list of required JAR files into lib folder for each applications separately. To overcome this problem by creating user libraries.

1.Select Window->Preferences


2. Enter Name for UserLibrary.
 
3. Add required JAR files into the UserLibrary.


 



  4. Add Hibernate Annotations JAR files.
   
   
  
5. Add MySQL database Connector/J jar file for MySQL Database Support

 

 In next post we discuss about how to setup the database development environment  in Eclipse IDE