Subscribe to rss rss

Java 7 – New Switch Statement

Posted by : | On : 07-03-2011 | Comments (1)
Java 7 – New Switch Statement
Java SE 7 is still just around the corner. It is still in Beta mode, so many things are still under test. TechieDan has been reading and researching about Java 7 in order to keep abreast of what Java has to offer in the coming future. There is this Project CoinFish that the Java people has put up that there are loads and loads of contribution. As of Java 7, one of these features is the new way of using SWITCH statements. I am sure most programmers would know that a switch statement is just like a if else statement. Though, the switch statement feels cleaner in terms of coding practice. public static void getLove() { int test = 1; switch(test) { case 1: System.out.println("This is number 1"); break; default: System.out.println("Chose no love"); } } The above is a sample switch statement if the method getLove() is called, it will print “This is number 1″. Of course, one thing that many people still uses the if statement is because it is able to compare with Strings. If (StringA.equals(StringB)) System.out.println("It’s the same"); Now fast forward to Java SE 7, you can now use Strings inside a switch statement. TechieDan will now explore this possibility with you and how it has changed in Java SE 7 onwards. It’s still in beta so you can wait till it’s finalized. Here I have a full complete source code so that you can run on your java source code editor and try to run it as an application. public...

Running Tomcat 5.5 on JDK 1.4 in Eclipse

Posted by : | On : 26-04-2010 | Comments (0)
Running Tomcat 5.5 on JDK 1.4 in Eclipse
For those running Tomcat 5.5 on a JDK 1.4, there will be compatibility issues. Testing it on Eclipse, the error would appear as such. This release of Apache Tomcat was packaged to run on J2SE 5.0 or later. It can be run on earlier JVMs by downloading and installing a compatibility package from the Apache Tomcat binary download page. This was what Eclipse would show if you came up with this error. Well, all one needs to do is to run the Tomcat on top a different Java Environment which is JDK 5 and above compliant. Here’s how to do it. On your Eclipse program go to Window > Preferences. Go to Server > Runtime Environments and select Apache Tomcat v5.5 and click Edit. Then you will proceed to this screen. Under JRE, change it to another JRE, they have to be JDK6 or jre6. Do note, please install the latest JRE (Java Runtime Environment) or get the JDK 6 to add it in as a JRE beforehand.

Setting up your JDK JAVA_HOME

Posted by : | On : 30-10-2008 | Comments (0)
Setting up your JDK JAVA_HOME
Setting up your Java environment to work on is as easy as how it seems to be. With Sun now offering executable JDK program, nothing much needs to be done. As of date, current JDK is the JDK 6.0 kit which was said to be powerful that the previous versions beforehand. Download and then install and voila, you’re good to run. All you need is to go into the bin folder of the JDK and run the javac and the java commands. This time I won’t be using an IDE though to explain t he procedure. If you wanna set up your environment variables on Windows, here’s how you do it on Windows XP. Right Click My Computer > Properties > Advanced > Environment Variables. Under User Variable for Users > New. Type the following. Variable Name : JAVA_HOME Variable Value : [Location of JDK folder] ex: D:\JDK6.0 After this you may now freely use your JDK to compile and run your code anywhere on the PC environment. I will touch on the compilation part using pure JDK later instead of an IDE in the coming parts.