Conor Mac Aoidh
http://macaoidh.name
conor@macaoidh.name
 

Search

Archives

  • December 2009
  • November 2009
  • October 2009
  • September 2009
  • July 2009
  • June 2009
  • May 2009
  • April 2009
  • March 2009
  • February 2009
  • January 2009
  • December 2008
  • November 2008
  • October 2008

Spam

3,964 spam comments
blocked by
Akismet

Tag Cloud

    bt broadband CMS conor's management system conormacaoidh conor mac aoidh content management system drums fast Fedora fedora 10 furasta furasta cms furasta org gnome guide hello world HTML icsp iPhone jar Java javascript joomla kde Linux Mandriva mc kennas Monaghan Music mysql php Scratch stealing the ceiling The Dominican Affair the pot smoking pirates the strats tutorial Twitter updates web design forum webme webworks weekly tweets Windows wordpress

Ads

Creating A Jar Archive

Posted Apr 27th, 2009 by Conor in in Java, Languages

I made the HelloWorld class a few days ago in this post. I am getting a bit ahead of myself here but what if you have an application with many files? Do you let the user handle all those files yourself? No! The Java Archiving Format .jar is the solution. With it you can create an entire application and bring it down to one file. Then you can run the whole application from that file! This can be done with the option of compression aswell.

Anyway even though it seems useless to create a jar archive of one file I am going to create one for the HelloWorld.class. First I need to create a file in which to store the manifest. This file will contain crucial information about the application and how it is run. I am going to do the bare minimum at the moment but there are endless possibilities with this file! This is what I put in HelloWorld.mf:

Main-Class: HelloWorld
Name: class/
Sealed: true

The main class tells the application which class to load first. Name and sealed tell the application which folders to seal. You might want to seal a package to ensure version consistency among the classes in your software.

I now have two files; HelloWorld.class and HelloWorld.MF. Now I must compress them both into a jar archive and run the application. To create the jar archive execute:

jar cmf HelloWorld.mf HelloWorld.jar HelloWorld.class

Basically this says create a new jar archive including the manifest and the class file and locate it in a new file called HelloWorld.jar. Now the application is executable. To run it simply type:

java -jar HelloWorld.jar

You should see the same output from the original application:

[conor@host java]$ java -jar HelloWorld.jar
Hello World!

Simple as that!

No responses yet

Twitter Weekly Updates for 2009-04-27

Posted Apr 27th, 2009 by Conor in in Twitter
  • Getting excited about the big gig on Wednesday!! It will be epic #
  • @BuzBuz are you thinking of going to the gig tomorrow? in reply to BuzBuz #
  • Started reading Learning Java by O Reilly #
  • @TweetDeck When I press the download link on your website it just says please wait and doesn’t do anything. Is there a backup direct link? #
  • @blacknight how long does it usually take for a domain to transfer? I did it a few hours ago and it’s still pointing to the old site… #
  • @blacknight the DNS is set to ns1.blacknight.com What does Subscription: Domain Only mean? I have done this before without problems… in reply to blacknight #
  • @BuzBuz Toxic Federation – there a good band and a great myspace page! #
  • I’m just after hearing that my band will have our own dressing room tomorrow night! That is pretty cool. The Tripod Dublin tomorrow @ 10pm #
  • @blacknight damn I knew I did something wrong. But I have added hosting to it anyway. Will that work? If not how can I change it? in reply to blacknight #
  • @blacknight :L ok i’ll just wait and see if the DNS updates. If not I’ll contact support! thanks in reply to blacknight #
  • @areyawell thanks! in reply to areyawell #
  • En route to Dublin for my gig in the Tripod! #
  • Phone found, in behind the bar in tripod… #
  • Ok fone bak all gud! WE WON THE BOTB YEAH!!!!!!! Playing UCD students ball on fri!! #
  • Day two of the Dublin party. can’t wait till the gig 2moro! #
  • Played a gig with sclub7 2day! Party still ragin lovin it! Best gig of my life!!! UCD students festival! #
  • @Out_Of_Step I’m n dub 2 with lisa and luke! What concert are you going to? in reply to Out_Of_Step #
  • Finally back from Dublin. We now have gigs lined up every weekend for the next month! 2 of them in Dublin! #
  • @brilliantthings wow you found me! :-) great gig yesterday guys! If your ever looking for a support act #domaff are available! :L #
  • @blacknight how can I check if/what PEAR packages are installed using my CP? in reply to blacknight #
  • @blacknight thanks for the link. Is it possible to install the MDB2_Driver_mysql package on my server? in reply to blacknight #
  • @Out_Of_Step Oh cool! We were playing in the Tripod on Wednesday and then the UCD Ball on friday. It was awesome! Iglu and hardy were there! in reply to Out_Of_Step #
  • I hate this.A great film just came on, now I must decide between watching it and being wrecked tomorrow or just going to sleep.I will watch! #
  • @Out_Of_Step Yeah even though there were feck all people there when we played it was still the best gig ever! in reply to Out_Of_Step #

Powered by Twitter Tools.

No responses yet

Hello World – Java

Posted Apr 26th, 2009 by Conor in in Java, Languages, Linux

I wrote my first Java application today. Ir is traditional to start out with something simple and boy this is simple and it works!

First you need to download and install the Java Development Kit (JDK) from Sun here. Then change directory to your workspace – where ever you want! In my case it was:

cd /home/conor/java

Then open up a new file named HelloWorld.java in your favourite text editor. In my case it was:

vim HelloWorld.java

Now we start the coding:

class HelloWorld{
  public static void main(String[] args){
    System.out.println("Hello World!");
  }
}

This is basically just a class that tells Java to output the words ‘Hello World! Now the code must be turned into machine code so that it is faster to run. To do that simply type:

javac HelloWorld.java

This creates a new file named HelloWorld.class which is written in machine code. If you open this file in your text editor all you will see is a load of gobledeegook. Now the application is ready to run. Type the following command to run it:

java HelloWorld

You should then see Hello World! written on your screen like this:

[conor@host java]$ java HelloWorld
Hello World!

Another one in the bag!

3 responses so far

Twitter Weekly Updates for 2009-04-20

Posted Apr 20th, 2009 by Conor in in Twitter
  • had a great gig tonight – in the four seasons. Unfortunatly they didn’t let us stay the night! :L #
  • I hate loosing games. #
  • good progress, made two websites today. I have to go home and make another attempt at #thedominicanaffair website aswell… #
  • I love punk music #
  • Another one in the bag! #
  • I’m looking up on converting the #mailing-list-plugin to Wordpress. After that Drupal and then the world…. #
  • ok wordpress plugins aren’t as easy as I thought… Damn OOP it’s so hard to understand! I’m getting there though! #
  • Damn it’s a slow morning… #
  • Another one in the bag! I have two websites left and then I’m free… #
  • @elliottkember what a cool idea with the excel thing! Oh and I love your website – JavaScript CRAZY!! :-) #
  • @timmillwood I concur Jimi Hendrix. But for the second I would revive Phill Lynnot in reply to timmillwood #
  • @Out_Of_Step I am going to Sligo 2nite 2 saras house parti! u goin? maad crac! #
  • I’m ripping – I missed the bus to Sligo!! Nooo :-( #
  • @Out_Of_Step I know I’m so pissed… was only 5 mins late… in reply to Out_Of_Step #
  • Earlier I asked my brother if he wanted anything in the shop. He replied “Yes, a United Ireland”. #
  • Another one in the bag!! Yeah. I’m finished and I beat my target! I completed 10 websites in seven days. Now that’s crazy :-) #
  • Working on a webme rss reader plugin… Interesting anyway #
  • Just finished another #webme plugin – Banner Image Plugin. It allows you to upload your own banner image to your website. #
  • Just walked for 25mins to the nearest shop. It was worth it. #
  • Ok still working on thedominicanaffair.com I just can’t get a design that I think is in-your-face enough… #
  • I got a new iPhone today! It’s nice not having a broken screen anymore! Jailbreaking as I speak… #
  • iPhone jailbreaking complete and I’m lovin it! #
  • #domaff are recording an ep as I write #
  • Man that was a good night out. Best in a long time. #
  • #domaff single Euphoria (Behind the Fridge) is going through the mixing stage… Recording is alright quality. #
  • @elliottkember Why pay for an app? Open source all the way! :-) in reply to elliottkember #
  • Back at school how I hate it…! #

Powered by Twitter Tools.

No responses yet
Next Entries »



Conor's Blog is powered by Wordpress | Template design by Conor Mac Aoidh