Life in code, apps and OS's

I found this website and thought I’d post the URL as I will be checking some of this stuff out soon and was kindly thinking of others who are also looking for Java Tutorials…

http://www.tutorialized.com/tutorials/Java/1

Advertisements

Creating a VB.net web browser is an extremly simple task. So much so that it’s a great way to introduce yourself the the language. We shall be using the full version of Visual Basic .Net 2008, but the express editions will work Perfectly fine. Let’s get started shall we?

First open VB and create a new Windows Forms Application. You should name your application something that is easy to remember so you don’t forgot what the folder is called, in this example I shall name it, creatively, browser.

image

Now you should have a empty .Net window. Here we shall start designing our browser. Using the toolbox on the right (if you can’t see the toolbox you

browserx

can open it with control, alt and x) we want to drag over the ‘Web Browser’ Control, contained in the Common Controls box. By default the Web Browser control will take up the whole application, we want to undock it so click the browser once and find the small arrow on the top right (see image below)

arrow

And then click the ‘Undock in Parent Container’. Now we can grab the edges of the web browser control and change it’s size. Ideally we want something the web browser to leave 60 pixels on the top of the windows application. Think about the browsers you’ve used and leave that amount of space for a toolbar. When you have the size of the browser window you want we need to make it expand when the main window expands. We do this by clicking once again on the browser window, then on the right looking in the properties menu and finding anchor. Here we click the drop down box and select the bottom, left and right and top. This will force the browser to expand to the right, left, bottom and top when the main window expands. Without this the browser would just stay the same size.

anchorx

Now in the space above the browser window we want to drag a Panel. You can catch the panel in the toolbox section, containers. A panel will enable us to collectively manage it’s objects, while also helping in the aspect of design. Resize the panel to hit each of the main windows edges and the very top of the browser element. You can use the arrow keys on the keyboard to align the panel. Once again we want to anchor the panel. This time we want to anchor to the top, right and left. We should now have something very much alike to what’s below

browsera

Now we want users to be able to navigate the browser to certain locations using an address bar. To insert a bar using the toolkit drag a text box into our top container. You can find the text box control in the toolbox, common controls section. We want to move the text box control to the very bottom of our container panel and expand it’s size to around 466 pixels. In the right properties menu we want to rename this text box to navbox.

navbox

Now we need to give the user something to click when he has entered the web URL, so for this we’re going to insert a button. We can once again find the button in the common section of the toolbox. Place this button next to the navigation text box. Rename the button searchbutton, then in the properties menu find the ‘Text’ element and type ‘Go’. For design aspects we will change this buttons flatstyle (once again in the properties menu) to Popup. Now resize the button to be as high as your text box.

Ok I’m sure you want to start coding now so let’s quickly move on to making your collection of form items into a browser! Double click on the Go button you’ve created and we should now be shown the code screen.

VB.net 2008 will automaticlly create some code because you double clicked on the code button, and our cursor should be contained within the Private Sub section of code. Here is where we shall start coding.

WebBrowser1.Navigate(navbox.Text)

Lets explain the above simple but powerful code. We first type WebBrowser1 which is the name of the web browser control we dragged onto the application earlier now we call a properties of the control, in this case we want to navigate the browser window, so, as one would expect we type navigate. Now we use brackets to define the value that we want to send the control. If you wanted to the browser to go to one set location you would use quation marks and then a url, for example

WebBrowser1.Navigate(“http://google.com”)

for example However we want to accept use input from our text box. Because we named this textbox navbox we can call it’s value using navbox.text. This means whatever is in the navbox at the time of the user clicking the button will be used as the value. Because it’s not a text string within the code we do not use the quotation marks.

You can now test your browser to see if you can navigate!

image

If all went well you will be able to navigate to any website. Because it uses the IE control if the user has flash installed the browser will be able to view flash, and do many more things IE can do. Of course our browser is not the most exciting yet is it? Lets add a few more important features for any browser!

First of all lets tackle the all important back button. Without back buttons people will be stuck on certain pages and they would not be able to use the browser effectively at all. For the back button we’re going to add yet another button the the browser, this time above the navigation box. We shall name this button backbutton and have it’s text value as ‘Back’. We shall also add a icon for a better cleaner look. To add a icon we shall click the button once and click the properties window, then find the image option. Click the … next to image which will bring up a window saying select resource and then click the import button and find your back image file. For best results use a 24×24 PNG Transparent button (I use this fantastic one). You now will need to change the TextImageRelation to ImageBeforeText. Now repeat these steps replacing back with forward and TextImageRelation to TextBefore Image.

Let’s get to coding these buttons. Double click the back button to once again return to the code window and type WebBrowser1.GoBack(), do the same for the forward button but replace GoBack with WebBrowser1.GoForward(). That’s all for this sort tutorial, on request I will expand with more features such as a search box, I would love to hear your input!

Click to download the source code!

I would just like to make you aware that the above tutorial is taken from the following URL: http://www.tutorialized.com/view/tutorial/A-VB.net-Web-Browser/38174 I therefore take NO credit for this work, I am only hosting this infomation in the unlikely event that the URL above becomes unavaliable or taken offline.

Hi everyone, sorry I havent been posting much recently this is mainly due to me being busy at work and on other projects I am currently working on such as my new web-based MMORPG (I will post more about this soon!)

Anyway so…

I have decided to start learning to develop applications in JAVA mainly my reasons for doing so are as follows:-

  • Java is platform independant (Runs on Windows, Linux & UNIX)
  • Java is maintained by Sun Microsystems (A big player)
  • Java is NOT developed or in anyways associated with Micro$oft!!!
  • Java is free and open-source.

I will be keeping my blog updated over the next couple of weeks with tips, tricks and how-to’s so others like me can learn and hopefully start developing some really awesome applications.

For now, please go and download the following peices of software if you intend to follow my tutorials in my up-coming blog posts…

Firstly we will need to download the JDK (Java Development Kit) This is required by NetBean’s (The Opensource IDE that I will be using), The JDK will enable us to test and deploy our applications this also intergrates with NetBeans to enable faster testing etc!! I have downloaded and currently using JDK 6 (Update 10), You can download your copy from here: http://java.sun.com/javase/downloads/index.jsp – To install just run the downloaded installer and accept all defaults.

Now, NetBean’s is a multi-language development IDE from what I have seen from it so far, It really is a good peice of kit, I have downloaded version NetBeans 6.1, You can download your copy from here: http://www.netbeans.org/downloads/, I simply download the bundle named (Web & JAVA EE).

When installing Netbeans you can simply follow the installer accepting the defaults if you want to however, I decided to uncheck the Application Server installation as I do not intend to using NetBeans nor Java to develop Web based application (As I am much more fulent with PHP)… So simply just untick the following two options from the installer.

  1. GlassFish V2 URL2
  2. Apache Tomcat 6.0.16

Then continue… You’ll then have to accept the license agreement and accept the program installation directory then the software will install application and all other required file etc. – The installer will use ~300MiB to install the IDE (So just be sure you have enough room on your PC) :).

So thats all for now folks, I will continue to play around with the software and post any interesting infomation etc as my experience as a JAVA developer grows 🙂

These days many more companies are using mixed IT enviroments using a mixture of Windows, Linux, UNIX and Mac’s and I for one am using a mixture of Microsoft Windows and Linux (Ubuntu). On my network I use a Microsoft Active Directory and want to be able to get all Server (Linux & Windows) as well as Desktops (Linux and Windows) to authenticate in a central location.

Since browsing the web I managed to find this cool package that can be installed on Ubuntu Hardy Heron (8.04) which enables you to add and authenticate Ubuntu 8.04 against a Windows Domain Controller (Microsoft Active Directory)

So here goes…

sudo apt-get update
sudo apt-get install likewise-open
sudo domainjoin-cli join fqdn.of.your.domain Administrator
sudo update-rc.d likewise-open defaults
sudo /etc/init.d/likewise-open start

Using the above commands you have installed ‘likewise-open’ which is the package that makes it possible for the Ubuntu client/server to logon to a Windows domain, added the client/server to the windows domain, updated the system services and then started the service.

Now that the LikeWise package has been installed you can now logoff (although I recommend full system reboot) and logon in this format:

DOMAIN\username

You need to ensure that you prefix the username with the Domain name.

The good points about this kind of setup is as follows:

  • Single username/password combination across entire network.
  • Enforces password policys
  • Likewise Open enables Linux, Unix and Mac authentication on a Microsoft network using Active Directory. A user can now interactively log in to the Linux, Unix or Mac machine using Active Directory credentials, and can access any kerberized services that the non-Windows machine hosts.

 

In this post I will be showing you how you can install a fresh copy of Ubuntu on a server using two Hard disk drives either ATA or SATA drives, I would recommend using proper server hardware as if one of the HDD controllers fail then you still wont be able to reboot your server immediately. For thoses who are not familiar RAID1 mirrors data identically over two (or more) hard disks.

1. Firstly enter your Ubuntu Server Compact disk into the CD-ROM tray and boot the server with it, When you get to the Partioning options menu you will need to select ‘Manual’ like shown below:

 

2. Next I created 3 partitions on both disks: 8 GB for /, 500 MB for swap and the remaining space for /home. Please note that at this stage the partition types must be “physical volume for RAID” (0xFD in fdisk) instead of “Ext3 journaling file system”. Also note how the first partitions of both disks are marked bootable (the B flag in picture 4). Without setting those partitions bootable you might not be able to boot your computer without a CD!

 

3. Setting partition type and bootable flag, Next I went up and selected “Configure software RAID” (picture 4).

 

4.Two disks with partitions for RAID1 volumes, Next I saved the modifications made to the partition tables (picture 5).

 

5.  Saving the changes, Next I created three (3) MD devices (each configured as RAID1 with 2 active and 0 hotspace disks — pictures 6-9).

 

6. Creating new MD devices.

 

7. RAID1 = mirror.

 

8. Two active devices.

 

9. No spare devices, Next I selected the physical disk partitions to be included in the RAID1 set (picture 10). It’s important to select two partitions with identical sizes so in my case md0=sda1+sbd1, md1=sda2+sdb2 and md2=sda3+sdb3.

 

10. Selecting MD components, Next I configured file systems and mount points for each RAID device. In my case “RAID device #0” is ext3 mounted on /, “RAID device #1” is swap and “RAID device #2” is ext3 mounted on /home (pictures 11-15).

 

11. File systems created on the RAID devices.

 

12. / filesystem created on the RAID device #0

 

13. swap created on the RAID device #1

 

14. /home filesystem created on the RAID device #2

 

15. All file systems configured, Finally I went down and selected “Done setting up the partitions” and selected “Yes” to write the changes made to the partition table (picture 16). From this point on the Ubuntu installation is a normal installation.

 

16. Saving the changes.

After installation and the first reboot I installed grub also on the second disk’s (/dev/sdb) master boot record (MBR). Without this the PC will not start if the first disk (/dev/sda) fails and is removed from the PC.

martti@ubuntu:~$ sudo grub-install /dev/sda

martti@ubuntu:~$ sudo grub
grub> device (hd0) /dev/sdb
grub> root (hd0,0)
grub> setup (hd0)
grub> quit

WARNING: There is a serious bug in Ubuntu 7.10 (see this and this for details) which makes the boot fail if one of the physical disks in the RAID1 set is missing.

Testing it out..

After installation I verified that all file systems (/, swap and /home) are really on the RAID1 disks.

martti@ubuntu:~$ grep /dev/md /etc/fstab
/dev/md0        /               ext3    defaults,errors=remount-ro 0       1
/dev/md2        /home           ext3    defaults        0       2
/dev/md1        none            swap    sw              0       0

martti@ubuntu:~$ df -h / /home
Filesystem            Size  Used Avail Use% Mounted on
/dev/md0              7.4G  586M  6.4G   9% /
/dev/md2               12G  159M   12G   2% /home

The status of all RAID devices can be checked from the /proc/mdstat file. Each mdN device contains two sdXN disks and each mdN device should have “2/2” and “UU”. More details can be seen with the mdadm utility.

martti@ubuntu:~$ cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
md2 : active raid1 sda3[0] sdb3[1]
      12659136 blocks [2/2] [UU]

md1 : active raid1 sda2[0] sdb2[1]
      489856 blocks [2/2] [UU]

md0 : active raid1 sda1[0] sdb1[1]
      7815488 blocks [2/2] [UU]

unused devices: <none>

martti@ubuntu:~$ sudo mdadm --query --detail /dev/md0
/dev/md0:
        Version : 00.90.03
  Creation Time : Wed Oct 17 16:45:59 2007
     Raid Level : raid1
     Array Size : 7815488 (7.45 GiB 8.00 GB)
  Used Dev Size : 7815488 (7.45 GiB 8.00 GB)
   Raid Devices : 2
  Total Devices : 2
Preferred Minor : 0
    Persistence : Superblock is persistent

    Update Time : Wed Oct 17 15:16:18 2007
          State : active
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0

           UUID : 1760de71:d6ca4125:8324c8dc:300ec7e1
         Events : 0.11

    Number   Major   Minor   RaidDevice State
       0       8        1        0      active sync   /dev/sda1
       1       8       17        1      active sync   /dev/sdb1

 Recovering from a failed disk..

Next I simulated a disk failure by disconnecting /dev/sdb. The system still boots but the status shows /dev/sdb1, /dev/sdb2 and /dev/sdb3 have disappeared from the system and how the /dev/mdN is marked as “degraded” in the status field.

martti@ubuntu:~$ cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
md2 : active raid1 sda3[0]
      12659136 blocks [2/2] [U_]

md1 : active raid1 sda2[0]
      489856 blocks [2/2] [U_]

md0 : active raid1 sda1[0]
      7815488 blocks [2/2] [U_]

unused devices: <none>

martti@ubuntu:~$ sudo mdadm --query --detail /dev/md0
/dev/md0:
        Version : 00.90.03
  Creation Time : Wed Oct 17 16:45:59 2007
     Raid Level : raid1
     Array Size : 7815488 (7.45 GiB 8.00 GB)
  Used Dev Size : 7815488 (7.45 GiB 8.00 GB)
   Raid Devices : 2
  Total Devices : 1
Preferred Minor : 0
    Persistence : Superblock is persistent

    Update Time : Wed Oct 17 15:16:18 2007
          State : active, degraded
 Active Devices : 1
Working Devices : 1
 Failed Devices : 0
  Spare Devices : 0

           UUID : 1760de71:d6ca4125:8324c8dc:300ec7e1
         Events : 0.11

    Number   Major   Minor   RaidDevice State
       0       8        1        0      active sync   /dev/sda1
       1       0        0        -      removed

Next I reconnected the disk and instructed the system to rebuild itself. After rebuild everything was ok again.

martti@ubuntu:~$ sudo mdadm --add /dev/md0 /dev/sdb1
mdadm: hot added /dev/sdb1

martti@ubuntu:~$ sudo mdadm --add /dev/md1 /dev/sdb2
mdadm: hot added /dev/sdb2

martti@ubuntu:~$ sudo mdadm --add /dev/md2 /dev/sdb3
mdadm: hot added /dev/sdb3

martti@ubuntu:~$ cat /proc/mdstat
Personalities : [raid1]
md2 : active raid1 sdb3[2] sda3[0]
      12659136 blocks [2/1] [U_]
      	resync=DELAYED

md1 : active raid1 sda2[0] sdb2[1]
      489856 blocks [2/2] [UU]

md0 : active raid1 sdb1[2] sda1[0]
      7815488 blocks [2/1] [U_]
      [>....................]  recovery =  2.8% (215168/7815488) finish=16.2min speed=9780K/sec

unused devices: <none>

That’s it.

After getting three old Dell Dimension L1000R desktop PC’s after work was going to throw them out I decided to turn one of them into a Linux server mainly for me to have sitting on the internet mainly to use for remote backups and remote access to documents and other stuff I want to keep safe and access securely over the net (SSH) and therefore decided to turn this moderatly powered Dell machine into a server that would be able to run on any internet connection I put it on (obviously would need to foward ports) but would use DynDNS for the domain name and IP Update service so regardless of if my IP address was to change (Which is likely if your ISP does not give you a static IP address or have not purchased one) so anyway, This little quick tutorial is how you can setup the DynDNS client using ddclient, Configure and ensure that it automatically checks and updates your IP address if required.

Step #1

First off if you havent already registered a DynDNS account you will need to do this by visiting the website at www.dyndns.com, They also have a how-to which is easy to follow and will let you know how you can register an account and create your Hostname. (click here for the How-to)

Step #2

Now to keep your username and password secure over the internet when the ddclient program updates your IP address we will send the username/password combination over an SSH-Tunnel (Secure Shell) so we will have to install a few packages using Ubuntu’s lovely APT tool, So at the console (as root user) enter the following command:

apt-get install ssh libio-socket-ssl-perl

Step #3

Now we install the ddclient (The program that is used to communicate with the DynDNS service and update your IP address with DynDNS if a change of IP is detected.), So again, logged on as ‘root’ issuse this command at the terminal prompt:

apt-get install ddclient

Step #4

The installation will now prompt you to answer a series of questons (if you havent already logged into your DynDNS account and created a Hostname you will need to do it now before going any further). The screens should now look as follows:

^ You will need to select ‘www.dyndns.com’ as your dynamic dns service provider as shown above.

^ You now need to enter your full domain name that you registered with DynDNS.

^ Obviously you need to enter your DynDNS Username as shown above otherwise anyone would be able to update your IP address and therefore hijack your domain.

^ Enter your DynDNS account password as shown above.

^ Finally type web as the DNS Interface to use as shown above.

Ok now basically the ddclient is now fully setup but we still have a little more work to do to ensure that our DynDNS username and password is send encrypted over SSH to the DynDNS Servers, So moving on we now need to edit the raw ddclient configuration file so as root, enter the following command at the Terminal:

vim /etc/ddclient.conf

This should now open the configuration file in VIM (A CLI text editor for Linux/UNIX) the coniguration should look something like this (the bold line is what we will be changing so pay attentsion:

# Configuration file for ddclient generated by debconf
#
# /etc/ddclient.conf


pid=/var/run/ddclient.pid
protocol=dyndns2
use=if, if=web
server=members.dyndns.org
login=your-dyndns-username
password=‘your-dyndns-password’
your-host-name.homelinux.net

Ok, So now change the use=if, if=web text to the following:

use=web, web=checkip.dyndns.com/, web-skip='IP Address'

Secondly add this to the top of the configuration file below the comment’s section (comments are prefixed with # (hashes))

ssl=yes
daemon=300

The above two lines that you just added to the configuration file tells ddclient to connect using SSL and to check for updates every 5 minutes (300 seconds).

Now we need to check that ddclient is set to run as a daemon (System Service) so again, lets open the next configuration file by issueing this command:

vim /etc/default/ddclient

Now the configuration file itself should look like this…

# Configuration for ddclient scripts
# generated from debconf on Tue Jan 29 20:23:32 CST 2008
#
# /etc/default/ddclient
# Set to “true” if ddclient should be run every time a
# new ppp connection is established. This might be useful,
# if you are using dial-on-demand
run_ipup=”false”


# Set to “true” if ddclient should run in daemon mode
run_daemon=”true”


# Set the time interval between the updates of the dynamic DNS name in seconds.
# This option only takes effect if the ddclient runs in daemon mode.
daemon_interval=”300″

Thats basically it, All we now need to do is to restart the ddclient daemon by entering this command at the console:

/etc/init.d/ddclient restart

I have now started putting a new website together for Zantastico on Sourceforge, People can now download and get infomation regarding Zantastico for both zPanel and CorePanel.

The website is located here: http://zantastico.sourceforge.net


  • How To Dyndns Ubuntu | Order Goods: […] DynDNS Client Setup on Ubuntu | Life in code, apps and OS’s – May 18, 2008  · 7 Responses to "DynDNS Client Setu
  • lizrandolph10886: Wonderful article! We are linking to this particularly great post on our website.nKeep up the great writing. Click
  • waseem Ahmad: Dear. i have a separate application server and a separate mysql database server. when i want to access the application server to login from the local