November 14, 2013

Symlinking Eclipse

1. SymLinking eclipse to executable package..
sudo ln -s /path/to/ecipse /usr/bin

2. Copy eclipse icon..
cp /path/to/eclipse/icon.xpm /usr/share/pixmap/icon.xpm

3. Create eclipse.desktop
gedit /usr/share/applications/eclipse.desktop

and copy the following in it..

[Desktop Entry]
Type=Application
Name=Eclipse
Comment=Eclipse Integrated Development Environment
Icon=eclipse
Exec=eclipse
Terminal=false
Categories=Development;IDE;Java;

P.S: Exec - path to eclipse executable and Icon - path to eclipse.xpm, i.e we can skip 1 & 2 by providing actual path to these 2 directives

May 17, 2013

Installing Hadoop on ubuntu 12.04

Its a simple procedure

1. Download the latest stable version from apache hadoop or from one of its mirror sites
2. Extract/Untar the content to a newly created folder named hadoop on local file-system.
3. Make sure you've already setup your environment variable for JAVA_HOME.
4. Create env. var. for HADOOP_INSTALL and point it to hadoop-directory.
5. Include the bin directory in PATH.
6. For the new version(2.0 based) include the sbin directory too in PATH.
7. If everything is successful from above install, to test..

Type in..


$hadoop version
If the following is displayed means hadoop is installed on your local machine
Hadoop 0.23.6
Subversion https://svn.apache.org/repos/asf/hadoop/common
   /branches/branch-0.23.6/hadoop-common-project
   /hadoop-common -r 1439589
Compiled by tgraves on Tue Jan 29 03:52:15 UTC 2013
From source with checksum ba089c8e3aa974e8ef5b8f6ada0f4c04
P.S - To add environment var in ubuntu, most easy would be to add it in .bashrc file which is present in HOME
- Open it with - "


$ gedit .bashrc
add following environment variable to it..
#Home where java is installed
export JAVA_HOME="/path/to/OpenJDK"
#Home where hadoop is placed
export HADOOP_INSTALL="/path/to/hadoop"
#Adding homes to path
add export PATH=${PATH}:/path/to/your/hadoop/folder/bin



April 27, 2013

TLS(formerlly known as SSL) on Tomcat

You obviously need JDK, tomcat container and eclipse pre-installed for this to work.

1. Create .keystore file
    - For this cd in to {java_home}/bin directory like below and execute the following script

$ cd ${JAVA_HOME}/bin
$ keytool -genkey -alias tomcat -keyalg RSA
note - After you input a password and some other irreverent details, keytool command will generate
          .keystore file in home directory

2. configure tomcat to use .keystore like below.
First cd in to tomcat_home/conf and open server.xml
$ cd ${TOMCAT_HOME}/conf
$ gedit server.xml &

find the following commented lines
<connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
    maxThreads="150" scheme="https" secure="true"
    clientAuth="false" sslProtocol="TLS">
uncomment them..

and put the following right below it..
<Connector SSLEnabled="true" acceptCount="100" clientAuth="false"
   disableUploadTimeout="true" enableLookups="false" maxThreads="25"
   port="8443" keystoreFile="/Users/alpha/.keystore"
   keystorePass="password"
   protocol="org.apache.coyote.http11.Http11NioProtocol"
   scheme="https" secure="true" sslProtocol="TLS"/>
note - change path to .keyStore and keyStorePass variable values as per your configuration.

Open tomcat-user.xml in eclipse, add role, username and password for tomcat

In web.xml, add security-constraint and login-config tag
<security-constraint>
     <web-resource-collection>
         <web-resource-name>CRUD-APP</web-resource-name>
         <url-pattern>/*</url-pattern>
         <http-method>GET</http-method>
         <http-method>POST</http-method>
     </web-resource-collection>
     <auth-constraint>
         <role-name>user</role-name>
     </auth-constraint>

      <user-data-constraint>
         <transport-guarantee>CONFIDENTIAL</transport-guarantee>
        </user-data-constraint>
 
        </security-constraint>

 <login-config>
     <auth-method>FORM</auth-method>
     <form-login-config>
         <form-login-page>/Login.html</form-login-page>
         <form-error-page>/LoginError.jsp</form-error-page>
     </form-login-config>
  </login-config>




Note: There is problem with WTP plugin in eclipse, eclipse wont pick up changes made in tomcat's server.xml file.
In order to make it work in eclipse, Just make sure you delete the tomcat server and create a new one with above specified details.

After implementing the above these were the results

If we access our app, with following url, note that, we are accessing th4 app with http and at port 8080.. like below..

http://localhost:8080/CRUD

But it changes to following..
Look closely the protocol changes to https and port no. to 8443(the default port of TLS)



Note: SSL is now called TLS(Transport Layer Security)

April 26, 2013

Most important trick in ubuntu

Incremental Search(one of the best tricks on terminal)

To understand the beauty of incremental search.. lets simply dig in subject..
create and open .inputrc file in home directory..

$ > .inputrc
$ gedit .inputrc

and add following to it..

"\e[A": history-search-backward
"\e[B": history-search-forward
"\e[C": forward-char
"\e[D": backward-char 

Now exit the terminal and simply type "cd" and press up or down arrow key to search the history of cd command

March 11, 2013

Installing Glassfish Application Server on Ubuntu

GlassFish is one of the free open source and production quality server

To install it on ubuntu with eclipse ide

Download it 1st from this link

Extract it to folder on you system

Now from Eclipse IDE
1st go to > Help > Marketplace > Glassfish Adapter(Glassfish tool for your version of IDE) > install it
2nd right-click on Server Panel > New > type in GlassFish > choose your specific version > Add > Provide the path to GlassFish directory

Bingo!
Watch out at server panel, you can see some new icons related to GlassFish server(just hover your mouse on them and read the tool-tip)

For People on windows(still)
- Have the JDK integrate with eclipse
- Follow the above mentioned steps
- Make sure, path to server is C:\glassfish3\glassfish, not C:\glassfish3\bin

Happy Coding!