Tuesday, September 29, 2015

Computer Graphics : Code For Cohen Sutherland Line Clipping !


It's high time you started coding...

And I don't know how this post helps...because I am just providing you the code...

Try coding yourself and refer my code if you want to. And if you are learning from my code (I know it's rare, still), please be sure about knowing the concept before checking my code, and I hope it's not too tough to understand.

Cohen-Sutherland Line Clipping Code

Tuesday, September 22, 2015

IP : Installing Surgemail and adding mail accounts and How to use


First, you need to download a file. Go to

http://netwinsite.com/cgi-bin/keycgi.exe?cmd=download&product=surgemail&

and choose your Linux distribution. I chose " Linux (All 64 bit variants) " since I have Ubuntu 64 bit.

After downloading, you should have a .tar.gz file , place it in your home folder and extract it by right clicking it. It should give you a folder named "mtemp" and if you don't have any extracting application, then open your terminal and type this 


tar -xvf surgemail_XYZ_linux.tar.gz

replacing surgemail_XYZ_linux with whatever your file is named. Like, my file is named as surgemail_70c2_linux.tar.gz , so i used this command : 


tar -xvf surgemail_70c2_linux64.tar.gz

Now you should have a folder named "mtemp". Now use the terminal and change the directory to this folder using 'cd' command. And now, type

sudo ./install.sh

With this, your installation should start. Press Enter when it asks if it's ok to install in the default the installation path.



Now, type "karupsmail.com" as the full domain name. And type the host name as "mail.karupsmail.com" and then username for web administration as "root" and password as "root" too, and retype it.



Now, it asks for email account for management emails and alerts, and tells the default is "root@karupsmail.com" and now, just press enter.

The installation proceeds.

And it will be complete in a few seconds.




Press enter to exit.

Now, the server is started. To check it, go to

http://127.0.0.1:7026

Now, you will see a web page with many options and buttons. Some of the options that we need are gonna be discusses below. One of them is "Create User Account".



Just click this button and you will be asked the details of the new user. Just type the username and password. And create two users, so that, later, you can use one to send and another to receive.

I have created users : "karuppiah" and "keshav" , with password as their username. So now, their email ids will be "karuppiah@karupsmail.com" and "keshav@karupsmail.com"


Now, you just have to click  "Manager Info" on top left and then click "Web Email Client" and then login to your email accounts to see a GUI interface.









But we have to write java code to actually send mails using code and not using these GUI stuff.

Here's a basic code for Sending and Receiving Text Mail for my mail server :



You can change the code according to your own surgemail configuration ! :)


And finally, you need two jar files : mail.jar and activation.jar which contain the packages which start with the name : javax.mail.x and javax.activation.y

And we import them like 

" import javax.mail.*;
  import javax.activation.*; "

Here are the two jar files :



Place them in

/usr/lib/jvm/Your-Java-folder/jre/lib/ext/

Where "Your-Java-folder" is the name of the folder (containing java files) based on whatever java version you have.

And to place them in the above path, you should have root permissions. So, do it through terminal, using sudo and cp commands. 

Saturday, September 12, 2015

IP : Java Servlet. Code for displaying "Hello World"


First install tomcat apache server using this post :

http://semlabs.blogspot.com/2015/09/installing-tomcat-server.html

I am assuming you have your tomcat files in /opt/ , or else, change the path accordingly in the below steps and replace "/opt/".

Put this "hello" folder in /opt/tomcat/webapps/

hello - code.

The above folder contains all the code needed to print "Hello World" in your server response page.

To start tomcat server, type these commands in the terminal :

cd /opt/tomcat/bin/

./startup.sh

and type this in your browser :

http://localhost:8080/hello/HelloWorld

This should print "Hello World".

Here "hello" is the web-app , and "HelloWorld" is the url map for the servlet class file, which is also named "HelloWorld".

This is how I coded this Servlet :
  • Created a folder called "hello" in /opt/tomcat/webapps
  • Created a folder called "WEB-INF" inside "hello" folder
  • Created two folders called "classes" and "src" in "WEB-INF" folder.
  • The "WEB-INF" and "classes" folders are very important and must be named same way. I mean, it is case sensitive, and is important.
  • To understand the hierarchy in a better manner, download my "hello" folder!
  • Then created HelloWorld.java and coded it based on Servlet programming and placed it in "src" folder.
  • Created web.xml and defined the servlet name, servlet class name and defined the mapping.
  • Compiled the HelloWorld.java like this :

         javac -cp /opt/tomcat/lib/servlet-api.jar HelloWorld.java




  • Placed the HelloWorld.class file produced the previous step in "classes" folder.
  • Started the server using commands mentioned above and checked the output.


  • To know more about what each of these things mean, and to also know how to code it, look at this pdf by tutorialspoint :

    Servlets

    For any doubts or problems, mail me. This is the most basic Servlet program. This should give you a feel of how to code Servlets! :)

    IP : Installing Tomcat Server in Linux


    I am showing the procedure using Ubuntu. And don't worry, installation procedure won't change for different Linux distributions. I am just mentioning that I am using Ubuntu.

    Installing Tomcat Server :

    Follow these steps with some slight modifications that I am mentioning:

    https://www.digitalocean.com/community/tutorials/how-to-install-apache-tomcat-on-ubuntu-12-04

    First of all, Mam was telling that there are some problems in installing tomcat using apt-get command, I suppose some packages will be missed. Not sure. So, I downloaded the tar file from the url :

    http://apache.mivzakim.net/tomcat/tomcat-7/v7.0.64/bin/apache-tomcat-7.0.64.tar.gz

    the link keeps changing, so if you get 404 File Not Found, go to http://apache.mivzakim.net/tomcat/

    and try downloading newer versions.

    Now, follow the steps in the Digital Ocean website from the "untar file" step using "tar" command. And where ever they say "~/path/to/tomcat" use "/opt/tomcat"

    After following all the steps, you should have all the files of tomcat in your /opt folder.