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

Thursday, October 27, 2016

Starting with EJB3(Eclipse and WildFly 10 embedded)


Here are to configure an eclipse project to run a small EJB3 example....

My current configuration is:
JDK 1.8.0_91
WildFly 10(WildFly embedded configuration for Eclipse, see here)
JBoss Tools 4.3.1.Final installed in Eclipse(see here)
Eclipse 4.5.1 Mars for JavaEE developer
all on Windows 10....

We configure two project. One for the server side application. The other one for the client; we create a Dynamic Web Project for this last one. With a jsp file, within a button that starts all the process flow.

Let's we start with the server side application.

1) Under Eclipse File --> New --> EJB Project
I choose the name StartingWithEJB3_ServerSideAppl




Choose "WildFly 10.0 Runtime"(or whatever WildFly version you have) under "Target runtime" combo menu.
Leaves default "3.2" under "EJB module version" combo menu.

Then you can click on Finish.

2) Now we have to created two classes.
All under "ejbModule" folder.
The first one will be our Stateless Session Bean.
The logic business class.
So, right click on the ejbModule folder --> New --> Other --> Session Bean (EJB 3.x)


Choose a new Java package, that will be created... I give com.test.server.business
Than choose the class name, I give StatelessServerBean
At State type choose Stateless,
and into "Create business interface" section select the "Remote" check field, and I put as name StatelessServerBeanInterface
This field will create the remote Interface for the stateless bean we have created.

This is the content of the com.test.server.business.StatelessServerBean class

package com.test.server.business;

import javax.ejb.Stateless;

/**
 * Session Bean implementation class StatelessServerBean
 * @author Maurizio Franco
 *         http://maurizio-franco.blogspot.it
 *         maurizio.franco@ymail.com
 */
@Stateless
public class StatelessServerBean implements StatelessServerBeanInterface {
    public StatelessServerBean() {
    }

    public String executeTestMethod() {
        return "executeTestMethod invoked!!!";
    }
}


This is the content of the com.test.server.business.StatelessServerBeanInterface interface

package com.test.server.business;

import javax.ejb.Remote;

/**
 * StatelessServerBean interface
 * @author Maurizio Franco
 *         http://maurizio-franco.blogspot.it
 *         maurizio.franco@ymail.com
 */
@Remote
public interface StatelessServerBeanInterface {
    public String executeTestMethod();
}



3) Now we provide to create the second application. The client side application. With a Dynamic Web Project.

Click on New --> Dynamic Web Project


I Choose StartingWithEJB3_ClientAppl as project name.
"JBoss 7.1 Runtime" as "Target runtime"
and "3.0" as Dynamic web module version.
In configuration I had leaved "Default Configuration for JBoss 7.1 Runtime".

Than click on Finish.

4) Under project root create a new folder, I call it resources.
Under it, create a new properties file, I named it jboss-ejb-client.properties
This is its content:

remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
remote.connections=default

remote.connection.default.host=localhost
remote.connection.default.port = 4447


remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false

After create it, we have to put it into the class path.
So right-click on the project, Properties --> Java Build Path --> Libraries
Click on the button, on the right, "Add Class Folder" and we have to flag the check button for resources folder under our project.



5) Under src folder now we have to create to packages.
com.ejb3.client.test and com.ejb3.client.test.servlet

6) Under com.ejb3.client.test we have to create to classes.
First one is ContextProvider.
It contains:

package com.ejb3.client.test;

import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

public class ContextProvider {

    private static Context initialContext;

    private static final String PKG_INTERFACES = "org.jboss.ejb.client.naming";

    public static Context getInitialContext() throws NamingException {
        if (initialContext == null) {
            Properties properties = new Properties();
            properties.put(Context.URL_PKG_PREFIXES, PKG_INTERFACES);

            initialContext = new InitialContext(properties);
        }
        return initialContext;
    }
}

7) The other one is EJBApplicationTestClient
It contains:

package com.ejb3.client.test;

import javax.naming.Context;
import javax.naming.NamingException;


import com.test.server.business.StatelessServerBean;
import com.test.server.business.StatelessServerBeanInterface;

public class EJBApplicationTestClient {
   
    public static void main(String[] args) {
        System.out.println(EJBApplicationTestClient.class.getName() + ".main - START");
        StatelessServerBeanInterface bean = doLookup();
        System.out.println(EJBApplicationTestClient.class.getName() + ".main - DEBUG - Call server business logic method: " + bean.executeTestMethod());
    }

    public static StatelessServerBeanInterface doLookup() {
        System.out.println(EJBApplicationTestClient.class.getName() + ".doLookup - START");
        Context context = null;
        StatelessServerBeanInterface bean = null;
        try {
            System.out.println(EJBApplicationTestClient.class.getName() + ".doLookup - DEBUG - Obtaining Context");
            context = ContextProvider.getInitialContext();
            System.out.println(EJBApplicationTestClient.class.getName() + ".doLookup - DEBUG - Generate JNDI Lookup name");
            String lookupName = getLookupName();
            System.out.println(EJBApplicationTestClient.class.getName() + ".doLookup - DEBUG - Lookup and cast");
            bean = (StatelessServerBeanInterface) context.lookup(lookupName);
            System.out.println(EJBApplicationTestClient.class.getName() + ".doLookup - DEBUG - remote server bean successfully looked up..");
        } catch (NamingException e) {
            e.printStackTrace();
        }
        return bean;
    }

    private static String getLookupName() {
        System.out.println(EJBApplicationTestClient.class.getName() + ".getLookupName - START");
        //The app name is the EAR name of the deployed EJB without .ear suffix.
        //Since we haven't deployed the application as a .ear, the app name for us will be an empty string
      
        String appName = "";

        //The module name is the JAR name of the deployed EJB without the .jar suffix - in this case is the name of the Project..
       
        String moduleName = "StartingWithEJB3_ServerSideAppl";

        //AS7 allows each deployment to have an (optional) distinct name.
        //This can be an empty string if distinct name is not specified.
        String distinctName = "";

        System.out.println(EJBApplicationTestClient.class.getName() + ".getLookupName - DEBUG - Get EJB bean implementation class name");
        String beanName = StatelessServerBean.class.getSimpleName();
        System.out.println(EJBApplicationTestClient.class.getName() + ".getLookupName - DEBUG - beanName: " + beanName);
       
        System.out.println(EJBApplicationTestClient.class.getName() + ".getLookupName - DEBUG - Get fully qualified remote interface name");
        final String interfaceName = StatelessServerBeanInterface.class.getName();
        System.out.println(EJBApplicationTestClient.class.getName() + ".getLookupName - DEBUG - interfaceName: " + interfaceName);
       
        System.out.println(EJBApplicationTestClient.class.getName() + ".getLookupName - DEBUG - Create a look up string name");
        String name = "ejb:" + appName + "/" + moduleName + "/" + distinctName    + "/" + beanName + "!" + interfaceName;
        System.out.println(EJBApplicationTestClient.class.getName() + ".getLookupName - DEBUG - lookup up name: " + name);
       
        return name;
    }
}

WARNING!!!! I pick the background to red to pay attention to the moduleName, it must be the server module name(normally the name of the server application gived to the eclipse project)

8) Next, under com.ejb3.client.test.servlet we create a Servlet class.
Its name is TestServlet and it contains:

package com.ejb3.client.test.servlets;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ejb3.client.test.EJBApplicationTestClient;
import com.test.server.business.StatelessServerBeanInterface;

/**
 * Servlet implementation class TestServlet
 */
@WebServlet("/TestServlet")
public class TestServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;
      
    /**
     * @see HttpServlet#HttpServlet()
     */
    public TestServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {       
        System.out.println(TestServlet.class.getName() + ".main - START");
        StatelessServerBeanInterface bean = EJBApplicationTestClient.doLookup();
        //Call server business logic method
        System.out.println(TestServlet.class.getName() + ".main - DEBUG - " + bean.executeTestMethod());        
    }


}




9) Now we have surely some errors on the Servlet and on the EJBApplicationTestClient class. Some classes used are not resolved.
So we have to import the jar file of the Server application.
So we do it right clicking on the Server Side Application, in my case on the 
StartingWithEJB3_ServerSideAppl project, (remember the Java EE perspective) go under "Export" --> EJB JAR file  

Our server application project selected in the EJB Project text field.
Than in the Destination text filed we have(with "Browse.." button) to point to:
%ECLIPSE_WORKSPACE_FOLDER/StartingWithEJB3_ClientAppl/WebContent/WEB-INF/lib






After give an F5 on the client project. Only with this forced refresh the project will see the server application jar.


10) We have at the last point. Create a simple jsp file to invoke all the process. A simple page that through the button pression will call the
TestServlet thats using the EJBApplicationTestClient class will invoke the remote(on the server) instance of StatelessServerBean to call the executeTestMethod()
The index.jsp contains:

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Jsp test page for invoke ejb3 test client class...</title>
</head>
<body>
    <form action="${pageContext.request.contextPath}/TestServlet">
        <h1>After clicking see the server console output....</h1>
        <input type="submit" value="invoke ejb3 client application"/>
    </form>
</body>
</html> 



That's all. 
You can find all this small example in a branch of sourceforge.net ready for download.
The urls for Anonymous download(no password required) are:

svn://svn.code.sf.net/p/mauriziofranco/code/StartingWithEJB3/trunk/StartingWithEJB3_Server 

svn://svn.code.sf.net/p/mauriziofranco/code/StartingWithEJB3/trunk/StartingWithEJB3_Client

Or for checkout directly from command line give these:

svn checkout svn://svn.code.sf.net/p/mauriziofranco/code/StartingWithEJB3/trunk/StartingWithEJB3_Server  mauriziofranco-code

svn checkout svn://svn.code.sf.net/p/mauriziofranco/code/StartingWithEJB3/trunk/StartingWithEJB3_Client  mauriziofranco-code

Bye...

Monday, May 30, 2016

Eclipse (4.5.2 "Mars"): configure WildFly 10 Application Server as local instance. The quick developer configuration.

My current environment is
JDK 1.8.0_91
Eclipse Mars 4.5.2
JBoss Tools 4.3.1.Final already installed(if not yet installed please see here)
WildFly 10 Application Server downloaded(from here) and installed.

1) Under Eclipse go under Java EE Perspective(in the high on the right, or click on "Window" --> "Open Perspective" --> "Other" --> and here find and choose Java EE)

2) In the low area, in the "Servers" tab, right click and choose New --> Server

3) Here choose WildFly 10.0 version, under JBoss Community menu folder:





4) Select the adapter options, as the image, type of server and as you want to control it:




5) Than point to the right home directory of your WildFly installation.






6) Then finish.

That's all. You have now a local instance of the WildFly 10 into Eclipse correctly configured...

7) Test it: right click on the server --> "Start"
Once WildFly is started, from browser point to http://localhost:9990


You should see something like this....(of course the screenshot above tells you how to create users to access administration console correctly.....)


Bye...

Eclipse 4.5.2 (Mars), installing JBoss Tools 4.3.1.Final for WildFly 10

Here we see how to configure JBoss Tools 4.3.1 under Eclipse(currently at 4.5.2 version, "Mars").
All for configure a WildFly 10 eclipse embedded environment setup.
Currently configuration has been done with JDK 1.8 version.

1) Under Eclipse, go on "Help" --> "Eclipse Market Place"

2)Fill with "jboss tools" the search text field, and search for JBoss Tools, currently I found 4.3.1.Final version as the image....


3) Go ahead throught the setup wizard...

4) After you restart Eclipse you are ready to setup the WildFly 10 embedded configuration...

Bye...


Friday, May 6, 2016

Starting with: REST web services, server and client examples.

1) Open Eclipse IDE
2) Create dynamic web project named "startingWithRESTWebServiceServer" (and set 3 at dynamic module version)
3)Download from jersey download page last available JAX-RS 2.0 API jar distribution
4)Unzip it and copy all jars under api, ext and lib folders under WEB-INF/lib
5)Ensure that you have your "Web App Libraries" configured in your project build path.
6) right-click on src folder and create a new package name com.webservices
7)Then create User class with this content:

package com.webservices;

import java.io.Serializable;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "user")
public class User implements Serializable {

   private static final long serialVersionUID = 1L;
   private int id;
   private String name;
   private String profession;

   public User(){}
  
   public User(int id, String name, String profession){
      this.id = id;
      this.name = name;
      this.profession = profession;
   }

   public int getId() {
      return id;
   }

   @XmlElement
   public void setId(int id) {
      this.id = id;
   }
   public String getName() {
      return name;
   }
   @XmlElement
   public void setName(String name) {
      this.name = name;
   }
   public String getProfession() {
      return profession;
   }
   @XmlElement
   public void setProfession(String profession) {
      this.profession = profession;
   }       
}


8)Then create UserDao class with this content:

package com.webservices;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.List;

public class UserDao {
   public List<User> getAllUsers(){
      List<User> userList = null;
      try {
         File file = new File("Users.dat");
         if (!file.exists()) {
            User user = new User(1, "Maurizio", "Fisherman");
            userList = new ArrayList<User>();
            userList.add(user);
            saveUserList(userList);       
         }
         else{
            FileInputStream fis = new FileInputStream(file);
            ObjectInputStream ois = new ObjectInputStream(fis);
            userList = (List<User>) ois.readObject();
            ois.close();
         }
      } catch (IOException e) {
         e.printStackTrace();
      } catch (ClassNotFoundException e) {
         e.printStackTrace();
      }       
      return userList;
   }

   private void saveUserList(List<User> userList){
      try {
         File file = new File("Users.dat");
         FileOutputStream fos;

         fos = new FileOutputStream(file);

         ObjectOutputStream oos = new ObjectOutputStream(fos);
         oos.writeObject(userList);
         oos.close();
      } catch (FileNotFoundException e) {
         e.printStackTrace();
      } catch (IOException e) {
         e.printStackTrace();
      }
   }  
}


9)Then create UserService class with this content:
10)Then create or update web.xml file(under WebContent folder) with this content:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns="http://java.sun.com/xml/ns/javaee"
   xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
   http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
   id="WebApp_ID" version="3.0">
   <display-name>startingWithRESTWebServiceServer</display-name>
   <servlet>
      <servlet-name>REST Wer Service server example</servlet-name>
      <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
         <init-param>
            <param-name>jersey.config.server.provider.packages</param-name>
            <param-value>com.webservices</param-value>
         </init-param>
      </servlet>
   <servlet-mapping>
   <servlet-name>REST Wer Service server example</servlet-name>
      <url-pattern>/rest/*</url-pattern>
   </servlet-mapping> 
</web-app>




11)Now we are ready to deploy the application.
So deploy the exported project as war file under tomcat or configure it internal bundled and add the project to it.
Then we can use a chrome plugin extension(as SimpleRestClient) to test it.
Pointing to url:
http://localhost:8080/startingWithRESTWebServiceServer/rest/UserService/users

That's all....
Bye...
 

Monday, November 9, 2015

Eclipse: installing egit plugin

Open eclipse, in the toolbar menu, under "Help" - "Install New Software"
Insert this url "http://download.eclipse.org/egit/updates" into the text field and click on the "Add" button.
Flags the "Eclipse Git Team Provider" and "JGit" check boxes.
You've done....

Friday, March 13, 2015

Eclipse: disinstalling plug-ins

For full removing installed plug-ins from Eclipse, go under

Help --> About Eclipse --> Installation Details(BUTTON) --> Installed Software(TAB)

then select plug-ins to remove....

Bye....

Wednesday, March 19, 2014

JPA and MySQL... quick smart guide(with Eclipse)

Here are to configure a small eclipse project to run JPA capabilities on a mysql database.....

My current configuration is:
JDK 1.6
Eclipse Kepler for JavaEE developer
MySql 5.5
Mysql_jdbc_connector (to connect your java application to mysql db)
EclipseLink 2.5 (provides advanced support for leading relational databases)
all on my Debian Wheezy.....

1)Under Eclipse, create a new "JPA Project".
Insert a custom name. Leaves all the default settings(none target runtime, JPA Version 2.1, Basic JPA Configuration).
Going ahead, setting "EclipseLink 2.5.x" in the Platform combo menu.
Next in the JPA Implementation menu select User Library, then with the button image "Manage Libraries" create twe variables with the relative mapping to three libraries, as above:
-  ECLIPSELINK alias variable that points to $ECLIPSELINK_HOME_DIR/*.jar (where *.jar means some of the libraries under the $ECLIPSELINK_HOME_DIR folder and his subfolders, please see the image above)
- MYSQL_CONNECTOR alias variable that points to $MY_SQL_CONNECTOR_HOME_DIR/mysql-connector-java-5.1.29-bin.jar

Alternatives to the manual mapping of the ECLIPSELINK jars you can click instead on the "Download library..." button and select the version of your Eclipse IDE installed(in this case Eclipse Kepler).
This procedure is automatic and avoids also to download manually the EclipseLink .zip file.



Under the Connection combo menu, click on the "Add connection..."
Select MySQL, Next, Near the Drivers combo menu click on "New Driver Definition".
Under the "Name/Type" tab, select MySQL JDBC Driver, with System Version 5.1.
Under the "JAR List" tab, click on the only showed mysql-connector-java-5.1.0-bin.jar and click on the right on the "Edit JAR Zip..." button.
Select the mysql-connector that you have previously downloaded....
Then click on OK.
Insert your database connection info....:
database name(custom)
URL(complete URL) --> jdbc:mysql://your_database_ip:3306/your_db_name
User name: your db applicative user name
Password: your db applicative password
Click on "Save password" check box
and on the right click on the "Test Connection" button.
Go ahead only if you have a correct response to this db test connection...
If no, solve before this problem. You must have the connection working...


 Then click on "Finish" button.

2) This is an example script used to create my custom table Users
CREATE TABLE Users (
        id INT(5) NOT NULL AUTO_INCREMENT,
        username VARCHAR(20) NOT NULL,
        email    VARCHAR(40) NOT NULL,
        password VARCHAR(20) NOT NULL,               
        PRIMARY KEY(id)
); 

3)This is the content of my persistence.xml(under src/META-INF folder)
<?xml version="1.0" encoding="UTF-8" ?>
<persistence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
     version="2.0" xmlns="http://java.sun.com/xml/ns/persistence">
     <persistence-unit name="JPATestProject" transaction-type="RESOURCE_LOCAL">
          <class>com.bean.User</class>
          <properties>
              <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/your_db_name"/>
              <property name="javax.persistence.jdbc.user" value="your_db_user_name"/>
              <property name="javax.persistence.jdbc.password" value="db_user_password"/>
              <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
          </properties>
     </persistence-unit>
</persistence>

4)I create 2 classes.
One to map the Users db table.
It is com.bean.User class and contains this:

package com.bean;

import java.io.Serializable;
import java.lang.String;
import javax.persistence.*;

/**
 * Entity implementation class for Entity: User
 * @author Maurizio Franco
 *         http://maurizio-franco.blogspot.it
 *         maurizio.franco@ymail.com

 */
@Entity
@Table(name="Users")
public class User implements Serializable {

      
    @Id @GeneratedValue
    (strategy=GenerationType.IDENTITY)
    private int id;
   
    private String username;
    private String password;
    private String email;
    private static final long serialVersionUID = 1L;

    public User() {
        super();
    }  
    public int getId() {
        return this.id;
    }

    public void setId(int id) {
        this.id = id;
    }  
    public String getUsername() {
        return this.username;
    }

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

    public void setPassword(String password) {
        this.password = password;
    }  
    public String getEmail() {
        return this.email;
    }

    public void setEmail(String email) {
        this.email = email;
    }
  
}

5) The other is the class that tests if all the game works...
com.test.Test is the class and contains this....:

package com.test;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

import com.bean.User;


/**
 *
 * @author Maurizio Franco
 *         http://maurizio-franco.blogspot.it
 *         maurizio.franco@ymail.com

 *
 */ public class Test {

    private static final String PERSISTENCE_UNIT_NAME = "JPATestProject";
   

    public static void main(String[] args) {
        EntityManagerFactory emf =
                Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
            EntityManager em = emf.createEntityManager();
                        
              //INSER new User
              em.getTransaction().begin();
              User appo = new User () ;
                       
             
              appo.setUsername("username123AAABBB");
              appo.setEmail("provaJPA_123");             
              appo.setPassword("password123");   
              em.persist(appo);            
              em.flush();
              em.getTransaction().commit();
              em.close();
             
              System.out.println("Inserted new User.... with username: " + appo.getUsername() + " - email: " + appo.getEmail());
             
             
//              //SELECT for id.....
//              int userId = 26 ;
//              appo = (User) em.find(User.class, userId);
//             
//              System.out.println("username: " + appo.getUsername() + " - email: " + appo.getEmail());
             
    }

}


Now you are ready to go....:-)

Run Test class and provides to do the insert test of a new User object.

 
Refer to this oracle documentation for other Accessing a JPA Entity using an EntityManager. Or the other Entity Manager capabilities....

Refer to these other links.... Eclipse info, eclipseLink JPA configuration, EclipseLink JPA Examples.


Bye....

PS.: You find the small project of above, available for anonymous download under source forge....
The url to point to checkout is this(ready to run under Eclipse with anonymous username and no password required) :
svn://svn.code.sf.net/p/mauriziofranco/code/StartingWithJPA/trunk/StartingWithJPA
Or you can checkout from command line with this:
svn checkout svn://svn.code.sf.net/p/mauriziofranco/code/StartingWithJPA/trunk/StartingWithJPA mauriziofranco-code

P.P.S.: remember to customize the persistence.xml....

Have a good job.....

Monday, November 25, 2013

Eclipse: quick SVN plugin installation...

On Eclipse toolbar choose Help --> Install New Software

On "Work with:" text input, on the right, click on "Add" button.

Insert new site point:
alias: SVN
URL: http://download.eclipse.org/technology/subversive/1.1/update-site/

The url point to the latest available version(november 2013) of svn releases.
You can check the latest available going on:
http://www.eclipse.org/subversive/latest-releases.php
and checking the Latest Stable Build paragraph,
in the "Update Site:" point.

After you entered those values, you can proceed with the installation click forward button.
If you want you can avoid to install SVN sources by not-checking the flag in the components-to-install menu .

Next restart eclipse.
After eclipse will ask you to choose a connector from a list; choose and go forward and all is done.

Bye



Thursday, January 24, 2013

How to set up CVS server under Debian 6.0.6, and connecting to it with Eclipse

First of all ensure you have ssh server....
If no see here....
After update repository indexes and install.....

apt-get update
apt-get install cvs


Now we see how to quickly configure it.....
create repository user and repository group

useradd repository

add user repository to repository group  

usermod -a -G repository repository

add user your_user to repository group

usermod -a -G repository your_user

create root directory for cvs

mkdir /home/repository

initialize cvs

cvs -d /home/repository init

give the right permissions to folders

chown -R repository:repository /home/repository
chmod -R 770 /home/repository
chmod 770 /home/repository/CVSROOT

Now provides to give the first import as cvs administrator, so in this case, as repository user I give the follow

cvs -d /home/repository import -m "Initial import" project_name username_that_add_the_first_sources project_version

Working with Eclipse, you go under New --> Other --> CVS Repository Location
and add as parameters...
- connection type: extssh
- host: hostname or ip of the machine where you installed the cvs, in my case localhost
-  username and password: the username, of system, that previously you added to the repository group and its password
- repository path: as in our example, /home/repository, that's the home directory that's you have setted for your cvs installation

Bye.....

Thursday, September 27, 2012

Developing an Android application with Eclipse.... Step 1 - Install the develop environment

After the never ended post of some months ago... here....
now we re-try to write a more complete article on starting to develop an app for Android using Eclipse, on a Debian distribution.

Well, we are on a Debian 6.0.4 squeeze, and we ensure to have a sun java installed and ready to use, please refer here.

After we provide to download and install eclipse, from eclipse downloads page, the "Eclipse IDE for Java EE Developers" version is good.
At the moment we have downloaded the "Juno (4.2) Packages".

From developer.android.com site download the right sdk for your operative system.
In this case we have a linux system, so we have downloaded(from http://developer.android.com/sdk/index.html) the archive file with our sdk:
http://dl.google.com/android/android-sdk_r20.0.3-linux.tgz

Provides to explode the two archive files.

Now we go under Android Sdk Installation folder, go into tools and opening a terminal,
launch the command:
./android sdk 
 
A window will prompted to you for show what the available packages to download. 
We suggest to flag Tools, Android API(currently the latest is the 4.1)and Extras.
At the end of the installation close the window.
Start Eclipse application, and go to.....:
Help > Install New Software
and add one between the following lines
http://dl-ssl.google.com/android/eclipse/
https://dl-ssl.google.com/android/eclipse/
 
Flag the checkbox with "Development Tools"....
 
..and install them(...the tools.....).
 
At the end of Development tools installation you need to restart eclispe.

When eclipse restart it will ask to you where is android sdk installation path
or to proceed to a new installation,
well you now can browse and point to our Android sdk installation.
Fine!!! You have completed the development environment installation.
In the next step we see how to starts to write an android application!!!
Bye...