VirtualBox and Windows

I thought of writing this post after the installation of Windows 7 in VirtualBox. This may be old news for some guys out there but still this can be new to some.
As I have told you earlier I don’t use Windows, Ubuntu dual boot anymore, now I solely depend on Ubuntu, it’s not that I hate windows but I’m uncomfortable with it ;) ok now lets get down to business.
First you have to install VirtualBox, to do that go to Applications -> Ubuntu Software Center and on search type VirtualBox and press install to install. After the installation go to Applications -> Accessories -> VirtualBox OSE and that will start virtualbox.
At first you have to create a new machine you can do by clicking on the light blue color new button after clicking on that you’ll get a window like this;

Create New Virtual Machine

so there you have to enter the name of the OS (You can give any name you like) and you have to select the OS type then after pressing next you’ll see a window like this;

Base memory

and there you have to select the base memory that means the RAM so the greener part of the bar shows the size that is available for the virtual machine. Let me explain this a bit, in my laptop I’m currently using 2.5Gb of RAM, that is shown at the end of the bar, that means for the host OS that complete capacity is available. But as I’m trying to run two operating systems at once I should be able to share the RAM so the greener part of the bar shows the safe side or the safe capacity that I can use and approximately its about half of the total capacity. So its better to stay on the safer side then you can use both the OSs without any problem (hope you got what I’m trying to say if not put some comment on that I’ll explain a bit more :) ). Now after pressing next you’ll get a window like this;

hard disk

Here we have to select the hard disk that means the virtual hard drive so now you have to create your first virtual hard drive (hope you are doing this for the first time). I’ll go to the creation of hard disk in a bit till then lets look at the final image of our virtual machine creation process.

Final

Now in the above image we can see the hard disk size is 20Gb and base memory is 955Mb etc.

Lets take a look at the creation of virtual hard disk. Ok now after selecting create a new hard drive and clicking next you’ll get a window like this;

create hard disk

In the above image we can see there are two radio buttons,

#Dynamically expanding storage :- That means the size of the hard disk will grow as you install more softwares and when you download more data. When you use this option make sure you have enough space on your physical hard drive.

#Fixed size storage :- This means the size of the hard drive is fixed.

After selecting the option you want click next then you’ll get a window similar to this;

harddisk name and size

In the above image I have given the name windows 7 and the size was given as 20Gb. Now in this case if you select dynamically expanding storage the whole 20Gb wont be allocated at once it will be allocated as the memory fills but if you use fixed size storage then 20Gb will be allocated at once. Therefore you have to allocate space according to your need. In the image you can see there is a little folder icon next to the textfield but clicking on that you can select the location of your virtual hard drive if you don’t change the path it will get saved in ~/..VirtualBox/HardDisks. After clicking on the next button you’ll get a summary like this;

summery

Ok now we are done with the creation of the machine and you’ll see your virtualbox window like this;

VirtualBox

Now it’s time to install the OS. Before doing that there are certain configurations you have to do. First of all you have to select the new machine you created and click on the settings button and from there when you click on General you’ll see a summary of what you have done so far. Now go to system and check the boot order here you can change the base memory once again (if you really need it). The image below is a screenshot;

System

And after that click on Storage if you are installing the OS using a DVD or CD image then you have to give the path of the image you can do that by selecting the CD icon in the storage tree and on the Attributes you have to click on the little folder icon and browse the image file. If you are planning to use the host CD/DVD drive you have to select the Host CD/DVD drive from the CD/DVD Device dropdown menu like the image below;

CDDVD

Now network settings, click on Network and click on the enable network adapter and cable connected check boxes and that will enable networking (and also remember you have to install samba server on ubuntu “sudo apt-get install samba”). After installing the OS you can access all the shared “Folders” in your computer by typing //10.0.2.2 on Run (For windows).

networking

And now we are good to install the new OS after installing it will look like this;

beforeGA

After installing Guest Additions you can have a full screen view like the image below;

afterGA

You can install Guest Additions by going to Device -> Install Guest Additions in the window which you get after clicking on the Start button. Now its your time to do your experiments.

Hope this was helpful
bye for now
have fun :D

~~ Rusiru Boteju ~~

RPC and RMI

Yeah I know this is after a looong time but what to do writing a post is not like writing a poem it takes time. I didn’t have any free time for the past few days but now I’m in a really good mood to write a post :D
This is basically an assignment we got from the subject called Middleware Architecture I’m not gonna talk about middleware now but this is a basic example of RPC and RMI. This might shock you but I’m gonna tell it to you it is… I did this using windows :-| I couldn’t find a way to do it in ubuntu its simply because I don’t have time to google it but there is something to tell you guys that is I did it in the virtualbox using Guest Additions makes it really cool it gives you the feeling that you are actually in windows ;)
Ok then lets get to the serious business (its not that serious at all simple like a piece of cake)
The following link has the codes you need to understand RPC and RMI
RPC and RMI Code

Now its time to tell you how this works first go to Windows ;) and open three command prompts go to the RPC folder from all the three command prompt windows

Example cd C:\RMI&RPC\RPC_example or cd C:\RMI&RPC\RMI_example

If you are in the RPC folder extract the orpc.jar file it will create two folders called META-INF and netbula now we are good to go.

Note this is the RPC part do this in the command prompt(cmd)

1. Type jrpcgen msg.x
2. Then javac ClientTest.java msgserv.java
3. Now javac msgsvc.java
4. Finally javac pmapsvc.java

this finishes compiling and now we have to run the code for that

1. Take the first terminal
2. Type java pmapsvc this runs the netbula server
3. Then type java msgsvc this runs the message server
4. Finally java ClientTest localhost this takes the commandline argument localhost

Now the testing part (this is a really simple demo)
when you run this you can see Hello World will get printed Five times now you have to do this
comment the following part

/*
String msg=”Hello World!\n”;
System.out.println(“Sending…”);
for(int i=0;i<5;i++){
String reply=c1.sendmsg(msg);
System.out.println("got"+reply+"\n");
}
*/

and now add this part instead of that

BufferedReader breader = new BufferedReader(new InputStreamReader(System.in));
while (true) {
System.out.println(“Your message :”);
String msg = breader.readLine();
if(msg.equals(“exit”)){
break;
}
String reply=c1.sendmsg(msg);
System.out.println(“got”+reply+”\n”);
}

and don’t forget to catch the exception which will be thrown by the BufferedReader and the InputStreamReader by adding these lines (hope you can get the difference)

}catch(rpc_err e){
System.out.print(“rpc: “+e.toString());
} catch (Exception e) {
System.out.println(“Exception :: ” + e);
}

and also don’t forget to import

import java.io.*;

now run the code again and you simply have to type something in the cmd where you ran ClientTest vola you can see the String you wrote in the cmd window where you ran msgsvc
Thats it!! you used RPC :D then its time for experimenting :D

Note this is the RMI part do this in the command prompt(cmd)

Yet again you need three command prompts
First go to cd C:\RMI&RPC\RMI_example or the folder with the RMI code

1. Run javac SampleClient.java SampleServerImpl.java
2. Finally then run rmic SampleServerImpl this will create some more class files

This finishes compiling now its the running part

1. Take a cmd type rmiregistry and hit enter
2. Then take the second cmd java SampleServerImpl
3. Finally type java SampleClient

And again now its time for you to experiment :D

Try it out and tell me I’m glad to help you in

~~ Rusiru Boteju ~~

Follow

Get every new post delivered to your Inbox.