Saturday, January 31, 2009

PHP In GlassFish

GlassFish is an App Server written in Java. So GlassFish does most of its work with the help of Java Servlets.

GlassFish does not have built-in support for PHP. Actually it can support PHP if a Java implementation of PHP exists for GlassFish. This was made available by Quercus Caucho at http://quercus.caucho.com/. Download the binaries and source of Quercus from the site.

Assuming that GlassFish is installed and its directory path is represented as "glassfish", proceed with the following steps -

  • Extract the contents of the archive downloaded from the Quercus Caucho website
  • Copy quercus.jar, resin-util.jar and script-10.jar from the WEB-INF/lib directory which is obtained from extracting the zip file to glassfish/lib directory
  • Open the file glassfish/domains/domain1/config/default-web.xml and add the following lines

<servlet>
<servlet-name>Quercus Servlet</servlet-name>
<servlet-class>com.caucho.quercus.servlet.QuercusServlet</servlet-class>
<init-param>
<param-name>ini-file</param-name>
<param-value>WEB-INF/php.ini</param-value>
</init-param>
</servlet>

<servlet-mapping>
<servlet-name>Quercus Servlet</servlet-name>
<url-pattern>*.php</url-pattern>
</servlet-mapping>

  • The first set of configuration indicates that there is a servlet available under the name Quercus Servlet and the second set of configuration indicates that the servlet is to be run whenever a file with php extension is encountered

That’s it, restart GlassFish and it should be now be compatible to understand PHP.

Configuring C, C++ In NetBeans 6.5

In Linux and Solaris NetBeans 6.5 configures itself using the gcc/g++ compiler which is available in several flavors of Linux to run C/C++ programs. However, in Windows, there isn’t any C/C++ compiler pre-installed, so we need to manually install a C/C++ compiler and configure NetBeans 6.5 with the compiler.

To achieve this, we use Cygwin - A Linux like environment for Windows. It contains several popular tools like gcc, g++, gmake, gdb, etc. Cygwin can be downloaded and installed from http://www.cygwin.com/.

Once the setup file is downloaded from the above mentioned site, it can be run as a normal .exe file. Cygwin supports three installation types -

  • Online installation
  • Downloading the installation files without actual installation
  • Offline installation form a local directory

Mention the directory path for the installation files. Also mention the directory where the downloaded files were placed. Offline install requires the packages to be downloaded and stored as a directory.

The installer will collect information from the parse-file and list all the packages that are available for install. In online install, this will list all the packages that are available to be downloaded and installed. Select the required packages to be installed and proceed. After some time, the installation completes.

Once Cygwin is installed, NetBeans automatically recognizes it and configures its C/C++ compilers. However if it does automatically recognize Cygwin, go to Tools > Options. Under the C/C++ tab, set in the parameters by mentioning the path of the base directory (the bin directory of cygwin), C compiler (gcc), C++ compiler (g++), make command and the gdb command.

That’s all; NetBeans is now configured to run your C/C++ programs.

NetBeans 6.5 Installation

Installation of NetBeans 6.5 requires Java Development Kit 5 or Java Development Kit 6 as a pre-requisite. You can download the required JDK from http://java.sun.com/javase/downloads/.

The installation procedure of NetBeans is the same in Windows, Linux and Solaris. Since NetBeans is written in Java, it is platform-independent and the installation User-Interface is also same in any operating system. NetBeans 6.5 is available as binaries for all the three Operating Systems - Windows, Linux and Solaris. Download it from http://www.netbeans.org/.

Start the installation by either double-clicking the .exe file in Windows or running the .sh file in Linux and Solaris from the Terminal. This starts the GUI based installation of NetBeans 6.5. Initially it takes a few seconds to configure the installer. The best part of NetBeans is its flexibility. It allows the user to install whatever is required, instead of installing everything. There are few runtimes which are selected by default.

Click on the customize button to select the runtimes which you need. The customize button also gives brief information about each component which is being installed. Also the GlassFish app-server and the Apache Tomcat web-server can also be installed as a part of NetBeans. Accept the license agreement.

Specify the installation directory of NetBeans. Also specify the directory where JDK is installed, the JDK directory is generally recognized by the installer itself. If you customized the installer to install GlassFish v2, the installer will prompt for the required parameters for GlassFish v2. These include the directory path, the admin username and password and the 3 ports - HTTP, HTTPS and admin. All these parameters are initialized to their default values.

Similarly, if you customized the installer for GlassFish v3, specify its directory path. Also, if you customized the installer for Apache Tomcat, specify its directory path.

The installer finally gives a summary of all the components which are to be installed, if you are satisfied with the customized components, start the installation. The installation will take some time depending on your system configuration and the components which are being installed.

Once the installation is complete, the installer will prompt you for registration. It is recommended that users register as there are a lot of offers available for registered users. However the choice of registration is left to the users. That’s it, NetBeans 6.5 is up and ready to use.

Run OpenSolaris 2008.05 In VirtualBox

This article emphasizes on how to load the OpenSolaris 2008.05 VDI image which was distributed as a part of a resource DVD distributed for college students by Sun Microsystems Inc.

The article is broken down into two parts - Installing VirtualBox and Loading the VDI image in VirtualBox.

Installing VirtualBox

VirtualBox is available in two versions on the resource DVD - 1.6 and 2.0. To install version 1.6 follow these steps -

  • For Windows go to virtualbox → 1.6 → win32 → (depending on your processor) amd64/x86
  • For Linux go to virtualbox → 1.6 → linux → (depending on your linux flavor) select the required package
  • For Mac OS X go to virtualbox → 1.6 → macosx → run the file present in the directory

To install version 2.0 follow these steps -

  • For Linux go to virtualbox → 2.0 → linux → (depending on your processor) amd64/x86
  • For OpenSolaris go to virtualbox → 2.0 → OpenSolaris → (depending on your processor) amd64/x86

The installation is simple and is similar to the other software that we generally install.

Configuring OpenSolaris 2008.05 in VirtualBox

Copy the "OpenSolaris_2008.05.vdi.gz" file from the opensolaris directory of the DVD and copy it to your hard-disk (This step isn’t necessary but will reduce the time taken for extraction of the final image).

Extract the contents of the file to a directory of your choice using software like Winzip (or) Winrar (or) IZArc.

You will get an *.vdi image which is nearly 8 GB in size (Caution - make sure your partition isn’t a FAT32 partition, as the extraction will be terminated at around 4GB if it is a FAT32 partition). Start VirtualBox by selecting Start → Programs → Sun xVM VirtualBox → VirtualBox. Select New Icon on the screen, a wizard will open which will guide you through the creation of the virtual Operating System, click on Next.

Type a name for the Operating system; it can be any name, no restrictions. Also select the type of the OS that is being used. In this case OpenSolaris. Specify the memory which you want to provide to the new Operating System. Remember your present Operating System is still running, so split the total available RAM accordingly so that both the Operating systems can work comfortably.

Next you will be prompted for a hard-disk to work with, select existing there. A screen, called the virtual disk manager, will appear where we are supposed to add our OpenSolaris image. Click on "Add", then browse through the folders and select the *.vdi OpenSolaris image (i.e. the extracted image). A new entry will be in the added in the virtual disk manager. Click on that entry and then click on Select.

The screen will come back to the hard-disk point. Now go to the next step. Finally a consolidated sheet of the selected options will appear. Select "Finish" here. Now as you can see there is a new Operating System waiting, under the name of OpenSolaris. Double click on it to get OpenSolaris working.

PPPOE Internet Configuration For OpenSolaris 2008.05

One of the first things I had to learn when I moved from Windows to OpenSolaris was to get my Internet up and running. I had an Airtel broadband connection which followed the PPPOE (Point to Point Protocol Over Ethernet) network protocol. I had to experiment a bit and due time got a proper process established for network configuration. So if you are also planning to setup a broadband connection in OpenSolaris, edit the following files accordingly -

/etc/ppp/pppoe.if

INTERFACE
And reboot.

/etc/ppp/peers/ISP

sppptun (what device to use)
plugin pppoe.so (initialize the connection)
connect "usr/lib/inet/pppoec INTERFACE" (connect string)
persist (if the connection dies, bring it back)
user "USERNAME" (username)
noauth (do not make the other side authenticate itself)
noipdefault (let them give you what IP they want to give you)
noccp (no compression)
novj (no compression)
noaccomp (no compression)
nopcomp (no compression)
defaultroute (add an appropriate default route)
usepeerdns (for dns)

/etc/ppp/chap-secrets

"USERNAME" * "PASSWORD"
Remember these are tabs and not spaces.

/etc/ppp/pap-secrets

"USERNAME" * "PASSWORD"
Remember these are tabs and not spaces.

Check your work by executing the following command at the terminal -

sppptun query

Sample Output

INTERFACE:pppoe
INTERFACE:pppoed

Execute the following set of commands to finalize the procedure -

rm /etc/resolv.conf (remove the resolv.conf file from /etc)
link /etc/ppp/resolv.conf /etc/resolv.conf (instead link the resolv.conf from /etc/ppp to the one in /etc)
vi /etc/nsswitch.conf (make sure "hosts" and "ipnodes" resolve through "files dns")

Start the internet connection by the following commands -

/etc/init.d/pppd start
/usr/bin/pppd call ISP

Remember many of these files require root privileges, so login as super user using the su command.

INTERFACE is found out from ifconfig from the terminal. Eg. e100g0
ISP is the service provider you are connected to. Eg. airtel
USERNAME is the user name with which you login. Eg. 04040142943@touchtel.india

Thursday, January 29, 2009

NetBeans 6.5 - Explore Practically

Following the NetBeans session on 24th January, we also conducted a small lab session the same day, where we provided the students with a lab and allowed them to explore the various features of NetBeans.

As the tech session conducted that day was an introductory session on NetBeans, we didn’t stress much on a specific project or language at the lab. Instead we allowed students to download NetBeans 6.5 from our local Sun Server and install it on the system. We also allowed them to configure Cygwin by providing them with a copy of Cygwin tools.

Besides this, they also tried a few C, C++ and Java programs depending on their interest. After the lab session, the students were confident that they could install NetBeans at their systems at home and start working with it. Besides this we also put up step-by-step guides for the students to install NetBeans 6.5 and configure C, C++ and PHP in NetBeans, just in case somebody has any problem installing it.

Introduction To NetBeans

After a long gap of 2 months, we had our second technical session last Saturday; that is on 24th January on NetBeans, the multi-lingual IDE from Sun Microsystems Inc.

After the OpenSolaris 2008.05, we planned to take up a topic which would reflect the dominance of a Sun technology on our curriculum. After giving in a lot of thought, we decided to take up NetBeans as our topic with emphasis on the fact that NetBeans can be used in every year of our four year tenure at Osmania University.

Once we decided on the topic of the session, we started preparing the concepts which would be discussed in the seminar. Keeping in view the 1st year and 2nd year students, we also planned a small pre-requisite presentation, so that they can understand the main presentation easily.

The concepts covered as a part of the seminar included

Pre-requisite Presentation

  • Programming
  • Programming Languages
  • IDEs
  • Databases
  • Servers

Introduction to NetBeans Presentation

  • Introduction to NetBeans
  • History of NetBeans
  • Installation of NetBeans
  • Feature overview of NetBeans
  • Technologies supported in NetBeans
  • NetBeans as a part of Osmania University
  • The NetBeans Community

Further, we also demonstrated how programming languages like C, C++, Java, HTML, CSS, JavaScript, XML, JSP, EJB and UML can be used in NetBeans. We also had a small demo covering PHP using NetBeans and GlassFish.

The entire presentation extended for about 2 to 2½ hours, and we ended it with an interactive discussion with the audience where their queries were answered and feedback was taken. We had a lot of positive comments and it was satisfying to see that the crowd understood what we wished to communicate. We thereby concluded the session stressing on the fact that NetBeans should be used by everyone.

We had a total strength of about 70 students for the event.

Wednesday, January 28, 2009

Sun Software Intranet FTP Server

At my college, a part of the curriculum is based on Java, namely Java Programming and Web development using Java.

After the OpenSolaris seminar and the Ref Contest, I gained reasonable exposure as the Sun campus ambassador among my classmates and my juniors including the 1stand 2nd years. So I was contacted occasionally for software relating to Java. A few other enthusiastic students also approached me for copies of OpenSolaris too. I distributed the CDs which were provided to me initially to most of them.

Our department has nearly 240 students. I am sure it is not possible for each and every one of them to approach me personally for the software. Also it is not possible for all of them to download the same via internet, as a few of them do not even have such a fast internet connection. Then we thought of coming up with something. At first we thought that we would put copies of software in the library, so that people can borrow them. Then we were suggested with a better idea - A Sun Software Intranet FTP Server.

We felt that this would make software distribution easy and human-independent. Because of this server, students would have the freedom to download any Sun software they need and easily work with them. Further as it was a local FTP site, we had very fast speeds while copying.

So we spent a few days talking with the system administrator of my department about this and collecting the required software. Our system administrator was very encouraging and supported us a lot. The HOD agreed at once, when we explained him the concept, and provided us with a spare system so that we could use it as the server.

We collected software such as

  • Gaming - Project Darkstar
  • GlassFish
  • Java SE
  • Java EE
  • JavaDB
  • JavaFX SDK
  • Jython
  • MySQL
  • NetBeans IDE
  • Open DS
  • Open ESB
  • Open Office
  • OpenSolaris
  • Open SSO
  • Project Wonderland
  • Sun Studio
  • VirtualBox

Further instead of restricting these software to a particular operating system, we put in binaries for the three popular Operating Systems including Windows, Linux and Solaris.

We finally started our server on 22nd January 2009 at the local IP of 10.10.12.113. This server is now accessible through about 150 computers across the department.

Friday, January 16, 2009

The Ref Contest - Winners

Finally, the first competition at Osmania University has come to an end. It was a great pleasure for the entire S.O.U.R.C.E Team to see such participation and enthusiasm.

The participation for the competition has been great and the total turnout was more than what we had anticipated. We had 12 students actively participating in the competition and the total strength of the group as of today is 470. We had students from over 50 colleges participating in the event.

Initially we planned to hold the competition till January 15th, but seeing the flood of people joining our group, we decided to close the contest early, as we expected that the high number would create apprehensions in a lot of people. However, we made sure that all the profiles were real and also created a database of all the members so that we can contact them when required. (The database is attached to the results discussion at the group)

On January 7th, we finally declared the results and distributed the prizes on 9th January. The following is the final list of points and the prize winners.

Arjun Kumar90
Mahmood69
Moeed Mohammad58
Shashank58
Suma25
Dontu Venkata Balasubramanyam23
Eranki Preetham12
Lingeswararao10
Amit Alam08
Syed Ameednuddin01
Hansraj00
Sri Kiran00

As, it is evident above, there was a tie and after a lot of thought and debate, the co-ordination committee of the S.O.U.R.C.E team decided that we would give 4 GB pen drives to both of them.

The 4GB Pen drives were given to Arjun Kumar, Mahmood, Moeed Mohammad and Shashank. T Shirts were given to Suma and Balasubramanyam.

As consolation prizes, the other participants were given a small gift hamper which consisted of a pen, a key chain, an OpenSolaris 2008.05 CD and a NetBeans CD.

A hearty congrats to all the winners!!!

Tuesday, January 06, 2009

The Ref Contest

As a strategy to propagate OSUM, the co-ordination committee of the S.O.U.R.C.E Team decided to host a competition for the students of the Computer Science Department of Osmania University.

After giving in a lot of thought, we came up with the name "The Ref Contest". The rules of the contest were pretty simple. They had to

  • Educate their friends about OSUM and FOSS
  • Ask them to join the S.O.U.R.C.E group of OSUM

For every person who enters, the participant was awarded with a referral point. Finally at the end of the contest, the participant with the most number of referral points wins!

The prizes for the competition were decided as

  • The top three participants would get a 4 GB pen drive each
  • Every participant who makes 25 referrals gets a T-Shirt. This was on "First perform, First win" basis

We decided to maintain transparency in the competition and finally concluded that the Discussion Forum at our S.O.U.R.C.E group was the best place to track the referral points. The referral points were calculated regularly and the positions were updated to keep up the competitive spirit.

The participants were also supplied with information about FOSS, OSUM, Sun Microsystems Inc and S.O.U.R.C.E, so that they can propagate OSUM effectively and efficiently.

We had great enthusiasm from the participants. They started spreading out the word to their friends and started the chain reaction. Within no time I could see the members in my OSUM growing by leaps and bounds.

The competition lasted for about a month, and is finally nearing an end. The results of the competition will be announced soon at http://osum.sun.com/group/osmaniauniversityosumsource/

OSUM - Truly Awesome

OSUM (Open Source University Meetup) is a global community of students that are passionate about "Free and Open Source Software". It was started in September 2008, and as of today it is a 39000 member community.

OSUM holds its ground, both as physical groups in various institutions and as a social network in the form of a social networking site, at http://osum.sun.com/

Osmania University is also a major contributor to the social network, in the form of the S.O.U.R.C.E group which takes care of all the on-campus events and a major community at OSUM, at http://osum.sun.com/group/osmaniauniversityosumsource/

The group mainly takes care of all the events at the Osmania University campus, which includes Tech-Sessions, Install-Fests, Competitions, etc.

The social community of Osmania University at OSUM consists of all the students interested and supportive of various events that happen at Osmania University.

The best part of OSUM lies in the fact that it can be totally customized to the taste of the user. As a part of OSUM, every student is given his/her own page, which can be modified to the max. Further OSUM also holds the capability for the student to add photos and videos of his/her choice.

Also, every profile has a blog attached to it where the student can add in blog posts, and share experiences with people across the world.

Well, besides all this, OSUM was started almost at the same time I joined Sun, and I am really happy to see its growth right from the beginning.

About Us

Free and Open Source Software

Free and Open Source Software is software which is liberally licensed to grant users, the right to study, change and improve its design through the availability of its source code. This approach has gained both momentum and acceptance as the potential benefits have been increasingly recognized by both individuals and corporate players.

Sun Microsystems Inc.

Sun Microsystems Inc. is a multinational vendor of computer components, computer software and information technology services.

Its contribution to field of hardware has been marvelous, especially with its SPARC architecture.

Sun has several software products to its credit, which include Solaris, StarOffice, VirtualBox, MySQL and several others.

And the most significant contribution of Sun Microsystems to the field of computers and electronics has been the "Java programming language", which is widely used in several devices, which include computers and mobile phones.

OSUM

As the leading supporter of Open Source, Sun Microsystems Inc. has established the OSUM (Open Source University Meetup), where people from all the corners of the world, interact to form a passionate community of students.

The site also concentrates on the fact that Open Source is changing (Y)our world and we need to be a part of that community.

Several groups and forums discuss and debate various topics concerning FOSS and contribute to the growing community of Open Source, here at OSUM.

S.O.U.R.C.E

S.O.U.R.C.E is the open source group of Osmania University, which strives to propagate open source technology across the campus, and spread the awareness of free and open source software, along with its benefits.

It plays a major role in spreading SUN technologies in the college in the form of tech sessions and install fests. It also holds up the spirit of FOSS among the students by conducting competitions and contests regularly.