How Java Class files are different ?

JavaYesterday one of my friend asked me a question “What is the difference between java class file and c++ class file? What will happen if I provide c++ class file to JVM ?”. The question is really a good question so I thought of writing this article to explain the Myths of java class file and a small comparison with malicious or class files from C++.  These class files are completely different from byte code to class loading and linking. Okie lets get down to business. Now answering the question mentioned above, Java class files are specifically designed for JVM (Java Virtual Machine) and all the .class files will be loaded and safely executed inside JVM.

Read More …

October 24th, 2008 | 1 Comment

How to redirect console output to file using Java?

Java ConsoleIn Java printing the program output to console for debugging purposes and sometimes for understanding the program flow is very common. Sometimes programmers feel comfortable if they are able to redirect the run-time exceptions and SOPs (System.out.println) to a file for future reference. Today I am going to write about redirecting console outputs and run-time exceptions to a file. One can always argue that we can use logging frameworks like log4j, java util logging by writing custom OutputStream class and using SOPs (System.out.println) is a bad practice. I too agree with that but this is just trick for beginners to understand the basics of java and one should always avoid using SOPs while writing applications.

Read More …

October 23rd, 2008 | 8 Comments