Monday, April 28, 2008

NetBeans IDE 6.1 Released

NetBeans IDE 6.1
NetBeans IDE 6.1 has been released. I had posted that it was to be released on April 23rd, 2008, but it didn’t happen. The NetBeans site latter on updated its release road map for an April 28th release. Why wasn’t it released on April 23, 2008? The NetBeans release guidelines states that there must be at least one week between the last release candidate and the final release. NetBeans IDE 6.1 RC 2 was released on Arpil 21rd, 2008, so exactly a week after it they have released the final version.


NetBeans IDE 6.1

Tuesday, April 22, 2008

Netbeans IDE 6.1 from tomorrow


Netbeans IDE 6.1 should be available for download at their site on April 23rd, 2008 as per their roadmap.





According to the site, NetBeans IDE 6.1 release provides several new features and enhancements, such as rich JavaScript editing features, support for using the Spring web framework, tighter MySQL integration, and an improved way of sharing libraries among dependent projects. The acclaimed support for Ruby/JRuby has been enhanced with new editor quick fixes, a Ruby platform manager, fast debug support for JRuby, and many other new features and fixes. It also promises performance enhancement which includes 40% faster start up time!

Since, the Netbeans community has given a green signal to the release candidates, let’s hope Netbeans 6.1 is out on April 23rd, 2008.

Monday, April 21, 2008

No source files with Java EE


I had installed JDK 6 that comes with Java EE, I wanted to have a look at the library source files (found as src.zip) in the JDK. But I couldn’t find it. I again downloaded JDK 6, and found the src.zip! So, sun doesn’t include the src.zip with the JDK that comes with Java EE. But why?

Sunday, April 20, 2008

Automating Archiving


The gmail blog published some 9 reasons as to why users should start archiving. People started to wonder why they should even bother, part of the concern due to them feeling the job repetitive. But it need not be. You can automate the process of archiving emails using filters!

After you enter into your mail account, find the “create filter” option near the search box, and click it.



The rest of the process is very simple that even a layman can figure it out, anyways, I will go through it. Now, you should have a yellow display asking you to “create a filter”. Here you define the criteria for the filter. I am going to enter “reports at sitemeter dot com” in the text box opposite to from, since I want to archive any mail sent from this mail address to me. Here I don’t want the reports from sitemeter to clutter my inbox neither do I want to delete it, as it may be useful as a future reference. There are also options to further refine your filter such as “subject” – which includes mails having the certain words in the subject to the filter.



Click “next step” after filling in the necessary parameters. This leads you to another set of options. Click “Skip the inbox(Archive it)” for archiving the mail. I also select “sitemeter” – a label I had already created, so that I can find all the mail from “reports at sitemeter dot com” in the “sitemeter” label. Click “create filter”.



A message displaying the parameters you choose and the actions that will take on those mails will be shown.



You have created a filter that will automatically archive your mails with certain parameters.

Saturday, April 19, 2008

Archiving mail, whats that?


…If that’s your answer to whether you archive your mail? (like me) or even if you did know what it is, but never cared to do so. Gmail blog, has come up with 9 reasons as to why you should archive your mail. Cut the crap out! What’s archiving? It just means moving mail out of your inbox and storing it for safekeeping. (Thanks to gmail blog for that short and simple definition!). So why should you do that? Here is why:

9. Phone numbers and addresses
You never know when you'll need a phone number someone emailed you or an address that was in a signature.

8. Procrastination
Sometimes you want to get a message out of your inbox, but you don't want to deal with organization, and you don't want to trash it.

7. Posterity

Just because you’re not famous now doesn’t mean that in forty years (or fifteen minutes) you won’t want to write your memoir.

6. Winning arguments
“But on May 5, 2005 at 8:43pm EDT you said….”

5. Mailing lists
Do you really need to know what Clintobamccain is doing every day? Auto-archive* their messages until you want to donate again.

4. Birthdays
Search for “grandma birthday” and voila, find the message you sent her last April. Aren't you glad you archived instead of deleted?

3. That guy
Remember that guy you thought you’d never need to get in touch with ever again?

2. Because you can

May as well use the free storage space. Plus, clean inbox = clean mind.

1. Fate-tempting is bad. You just never know
Thirty-one days after you send that message to the Trash and it gets permanently deleted, you're going to need it. Don't tempt the fates.

*To auto-archive, create a filter with the action "Skip the Inbox (Archive it)."


Reasons 9, 6 & 1 are something that I can really relate too. If not for anything you should give reason 7 a serious thought!


Why bother?


Some are confused as to why they should even bother to archive their mails, when Google offers you virtually unlimited space. If you ask me I can give you 2 reasons:

  1. If you are one of those persons, who receive a lot of mails (which haven’t been attended to) which makes your inbox look really cluttered and drives you so mad, that it makes you feel that you rather sign out or delete them. Then, archiving helps you to keep you inbox clean. And also if you use labels, it is just repetitive to have your mails shown in the inbox too.


  2. The next one is the most unlikely of the reasons. If you get so much mail that your (ever increasing) storage is almost full and you don’t want to delete the mails (I can’t figure out how that can be done!), you can make use of archiving and take full advantage of google’s free storage rather than deleting it.
Happy Gmailing!

Friday, April 18, 2008

Java for Space Technology



Sun Microsystems has announced that engineering and manufacturing company ITT Corporation has selected the Sun Java Real-Time System 2.0 (Java RTS) and the Solaris 10 Operating System (OS) as the software development platform for its Eglin Control and Signal Processing Upgrade (CSPU) program. The reasons for this according ITT:
…Sun Java RTS is an enterprise-class solution that addresses the issues of latency and unpredictable temporal performance of Java applications. It is compliant with the Real-Time Specification for Java and with Java Platform Standard Edition (Java SE). The solution enables hard, soft, and non-real-time functions to be combined in one system, while keeping critical latencies down to 20 microseconds. It enables developers to differentiate processes based on their importance and determine when time-critical functions should be executed.

It must noted that Java has been used in the controlling of Mars Rover!

Thursday, April 17, 2008

Is JVM platform independent or not?


Though java is platform independent why is that I need to download a different JDK based on my Operating System was the question I was asking myself, for some time. The major difference in these different JDK seems to be the JVM. JVM interprets the bytecode into actions or Operating System calls that performs the required functions. It was said to me that these Operating System calls are specific to those Operating Systems and hence the JVM is not platform independent. I searched my web on this, just to get confusing answers.

These are some posts from the SDN forums:

MLRon writes:

JVM is not platform independent. The code you write to run on a JVM should be (unless you interface to native methods). If Microsoft comes up with an operating system that isn't compatible with Windows, then they (or someone) will have to make a new JVM for that new operating system. The Windows JVM is different from the Unix JVM or the Linux JVM. But, your Java code can run on all three without being changed or recompiled (again, unless you interface to native methods, or use other platform-specific stuff).


Herko_ter_Horst writes:

Java "the language" is platform-independent. To make it so, there is a platform-specific JRE that knows how to run the platform-independent Java code on a specific platform.

The JVM could be called platform-independent because it produces the same results running the same Java code on different platform(*). It is however (at least partially) implemented as a platform-dependent executable.

(*) assuming you don't try to use such things as Windows-specific file-names on Linux and all that

Jverd writes:

However, there are two big things here, both of which others have been trying to tell you:

1) With Java, you don't have to recompile. You pick up the .class file, move it over, without the source code, and it runs fine (provided you have a compatible VM on your target platform. The VM is not platform independent, but the Java source code is).

Arul writes:

[my comments: He says this replying to why JVM is not platform independent] Because the Java Virtual Machine is available on many different operating systems, the same .class files are capable of running on Microsoft Windows, the Solaris , Linux, or MacOS. Some virtual machines, such as the Java HotSpot Virtual Machine , perform additional steps at runtime to give your application a performance boost. This include various tasks such as finding performance bottlenecks and recompiling (to native code) frequently-used sections of your code. [my comments: these exact words are used in Sun's Java Tutorial]

a.java --> compiler --> a.class [class files do not have code native to your processor, it instead contain byte codes]

a.class --> Interpreter JVM for solaris --> Solaris
a.class --> Interpreter JVM for Windows --> Windows and son

Now to other sources:

Webopedia:

...JVM is a platform-independent execution environment that converts Java bytecode into machine language and executes it....


Wikipedia:

....Although Java programs are Platform Independent, the code of the Java Virtual Machine (JVM) that execute these programs are not. Every supported operating system has its own JVM.

The Java Virtual Machine Specification, Second Edition:

Sun's current Java virtual machine implementations, components of its JavaTM 2 SDK and JavaTM 2 Runtime Environment products, emulate the Java virtual machine on Win32 and Solaris hosts in much more sophisticated ways. However, the Java virtual machine does not assume any particular implementation technology, host hardware, or host operating system. It is not inherently interpreted, but can just as well be implemented by compiling its instruction set to that of a silicon CPU. It may also be implemented in microcode or directly in silicon.

So what does it mean, is JVM platform independent or not?

Wednesday, April 16, 2008

System.arraycopy vs. Iterative loops for copying arrays



Well, I must say I am totally bewildered. Reading into “Java 2: The Complete Reference” by Herbert Schildt, I stumbled upon a method called “arraycopy()”, defined by the class System. This method is supposed to copy one array into another. This what the book says about the method:

The arraycopy( ) method can be used to copy quickly an array of any type from one place to another. This is much faster than the equivalent loop written out longhand in Java....


A quick search in the web about the method conformed this, a website recommending the use of arraycopy() over iterative method says:

….Besides accomplishing the same result with less code, this approach has the added advantage of being faster, since arraycopy is implemented as a native method, and will generally execute faster than equivalent code written in Java. This advantage can be particularly significant with large arrays or where many arrays are being copied.


So, I decided to try out how much quicker is System.arraycopy over iterative loops. So, I wrote a java code to test it out:


public class TimeCompare {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
int a[] = new int[1000000];
int b[] = new int[1000000];
int c[] = new int[1000000];
long start, end;

for(int i = 0; i < 1000000; i++){
a[i] = i;
c[i] = i;
b[i] = i+1;

}


start = System.currentTimeMillis();
for(int i = 0; i < a.length; i++){
a[i] = b[i];
}
end = System.currentTimeMillis();

System.out.println("Time taken to copy in milliseconds: " +
(end - start));

start = System.currentTimeMillis();
System.arraycopy(b, 0, c, 0, c.length);
end = System.currentTimeMillis();

System.out.println("Time taken to copy in milliseconds: " +
(end - start));

}

}


The logic is to get the start time, end time of the iterative way of copying and thereby calculate the total time it takes to complete the operation. Similarly, I also find the time taken by System.arraycopy and print it out both (iterative method followed by System.arraycopy). I am at loss to explain what I saw when I ran the program.

During my first execution, I got an output along the expected lines (iterative method takes more time to run):



Just out of curiosity, I ran the program using command prompt to see if it takes lesser time than using the IDE. This is what I got!



Iterative way, takes far less time than arraycopy!

Bewildered, I ran it two more times. Thankfully, the arraycopy method faired better, though the iterative method clocked different times – that is expected considering the load of the CPU during the execution.




But then, I returned to Netbeans IDE and ran the program again. This is what I got!




Both have taken almost the same time (I say almost in spite of both being 0, because the difference might have been subtle to be displayed in scale of milliseconds).

I ran it again. System.arraycopy() takes more time than iterative method!




So why is there so much discrepancy each time I run the program? How faster is System.arraycopy() , than the iterative method? If you know the answer please do write it down as a comment.

Tuesday, April 15, 2008

How to rename file extension


You may occasionally want to rename the extension of your files. For instance, once I downloaded a “.chm” file – HTML help file, which didn’t have an extension. So, I had to add the extension my self. I made an error by renaming it to a “.pdf” file. Now I wanted to correct it, but the extension is not visible when you try to change it. If something like this has happened to you it is because the windows, is configured to hide the extensions of known file types.

Now lets consider the file “SSHClientHelp” for example. It doesn’t have an extension visible, for the file to work properly it must be a HTML help file, but now it is a PDF file.



To enable the extension, go to tools –--> folder options, click the view tab and uncheck “Hide the extensions of known file types”





Now the extension must be visible, rename as usual.





Windows will ask you to verify your action, click yes. You are done!

Monday, April 14, 2008

Adding Digg button to blog posts





Finally, added the Digg button to the blog. But I still didn’t manage to change the template.

Tips-for-new-bloggers, has tutorial on how to add the dig button to the template. It asks to find the following line of code in the template:

<p><data:post.body/></p>

And then asks to add the following code on top of that line or below it depending on whether you need your dig at the top or bottom of your post.

<div style='float:right; margin-left:10px;'>
<script type='text/javascript'>
digg_url="<data:post.url/>";
</script>
<script src='http://digg.com/tools/diggthis.js' type='text/javascript'/></script>
</div>

When I do this, blogger takes me to a error page.



I searched the web for some other way, but almost all of them have got the same way of adding the Digg button. Failing in my attempts to add Digg button through a template fix, I decided to add it in each and every post.

First, publish your post. Then add the following code to the beginning of your post, by editing it:

<script type="text/javascript">
digg_url = 'WEBSITE_URL'
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>

Replace WEBSITE_URL with the URL of your blog post. Voila! You should see the Digg button!

But there is one trivial problem, the Digg button may seem out of place from your post. The text and button may be disjoint.



You can fix it easily by borrowing from the previous template fix discussed. Place the <div style='float:right; margin-left:10px;'> before the script tag and close it at the end. Like this:

<div style='float:right; margin-left:10px;'>
<script type="text/javascript">
digg_url = 'WEBSITE_URL'
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div>

You should see a digg button that seems to merge with your post.



Remember, you still need to change WEBSITE_URL with the URL of your post. Otherwise you will be digging your blog rather than a specific blog post.

But there is one disadvantage with this method, you need to do this for every post, unlike the template fix.

If anyone is aware of a working template fix please do mention it, in the comment section.

Sunday, April 13, 2008

Why not outlook?


This is my first post, and let me get to the issue straight away.

I was going through Java 2: The Complete Reference” by Herbert Schildt, there is this chapter on java.lang, in which there is a discussion of the methods of a class called Runtime.

A method called exec() is introduced which can call other programs. It seems similar to what happens in when you type notepad in Start ----> Run. In here, if you pass notepad as an argument to the method it would invoke the program. Here is the example program that the book gives:


public class ExecDemo {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Runtime r = Runtime.getRuntime();
Process p = null;

try {
p = r.exec("outlook");
p.waitFor();

} catch (Exception e) {
System.out.println("Error Opening outlook.");
}

System.out.println("Outlook Returned: " /*+ p.exitValue()*/);
}
}



It seems to work fine, but when I replace notepad with outlook.


p = r.exec("outlook");


It doesn’t work anymore. This is what I get in the output screen of my IDE (NetBeans):



So I commented off p.exitValue(), which is supposed to return 0 if the process (called) terminated normally or else it is supposed to return 1. The program degraded gracefully by calling on the exception:




The problem seems to be with the call to outlook. Does anyone know why it is unable to call outlook?