iReport 5 0 finding your way around

iReport is used to design your report templates. Here is the high level diagram of the key buttons and windows. If any of the windows are not there, you can add them from the menu item "Window".


The report is divided into "bands" and you can drag and drop report elements from the "palette" into the relevant bands. You can define the band and report elements properties via the "properties" window. New parameters, fields, etc can be added from the "Report Inspector" by right-clicking to bring up the contextual menu.

You can bring up the contextual menu on a "report element" as shown below to perform relevant tasks. Here is an example on a "Static Text" report element.


You can also bring it up on a "Text Field" report element as shown below. The "Edit expression" brings up the expression editor.




Finally, you can view it on three different layouts.

1. Designer (as shown above)
2. XML (shows the .jrxml file)
3. The Preview in your preferred output like "PDF Preview", "HTML Preview",  "XLS Preview (Using JExcelAPI)", etc that you select from the top "Preview" menu. This allows you to preview the actual report generated.


Read More..

Why use Override annotation in Java Coding Best Practice

@Override annotation was added in JDK 1.5 and it is used to instruct compiler that method annotated with @Override 
is an overridden method from super classor interface. Though it may look trivial @Override is particularly useful while
overriding methods which accept Object as parameter just like equals, compareToor compare() method of Comparator 
interface. @Override is one of the three built in annotation provided by Java 1.5, other two are @SuppressWarnings and @Deprecated. Out of these three @Override is most used because of its general nature, while @SuppressWarnings is also used while using Generics, @Deprecated is mostly for API and library. If you have read my article common errors while overriding equals method than you have see that one of the mistake Java programmer makes it,  write equals method with non object argument type as shown in below example:
Read more »
Read More..

5 ways to check if String is empty in Java examples

String in Java is considered empty if its not null and it’s length is zero. By the way before checking length you should verify that String is not null because calling length() method on null String will result in java.lang.NullPointerException. Empty String is represented by String literal “”. Definition of empty String may be extended to those String as well which only contains white space but its an specific requirement and in general String with white space are not considered as empty String in Java. Since String is one of the most frequently used class and commonly used in method arguments, we often needs to check if String is empty or not. Thankfully there are multiple ways to find if String is empty in Java or not. You can also count number of characters in String, as String is represented as character arrayand decide if String is empty or not. If count of characters is zero than its an empty String. In this Java String tutorial we going to see 5 ways to find if any String in Java is empty or not. Here are our five ways to check empty String :
Read more »
Read More..

Top 10 Google Interview Questions Answers for Software Engineer Books Resources

These Google interview questions are some of my favorites collected from different sources. Every Programmer know that Google is one of the best technology company and its dream for many software developer to work for google, but at same time interview process at google is very tough and only few genuine intelligent programmers get through there interview process. Google interview questions are always been a good topic of discussion when few young software developer gathered around, I can still remember when one of my friend got call from google for interview then how whole bunch was got excited. We have searched a lot on internet on google interview questions and answers for him and us and then make a note of some of the best questions for preparation. I am listing down some google interview questions from that list. Apart from the popular questions asked in various Google Interview for software engineers or developers, books on algorithm and data structure plays a lot more important roles. Books like Algorithms for Interviews and Introduction to Algorithms are must read for any Programmer, who is serious about converting Google interview or similar companies like Facebook, Amazon and Microsoft. Once you start preparing for Google, rest of them become very easy.
Read more »
Read More..

Source control system and subversion aka SVN questions and answers

Q. Why do you need a source control system?
A. Source Control systems like subversion is a must if you are writing Java code by yourself or as a team. It allows multiple streams of coding, tracks the changes in your code and allows you to roll back to previous versions.  Here are the benefits of a source control system.

  • Have you ever realized that you have made a mistake and wanted to revert back to your previous revision? You also dont lose your code. You can experiment with things., and if things dont work as expected, you can revert your code.
  • Multiple streams or projects can work simultaneously on the same code base by branching the code from trunk, and then merging the code back to trunk and then tagging it prior to releasing and deploying the code.
  • Versioning helps you look at previous versions of the code to find out when and where bugs were introduced. You can compare two different versions of code side by side.
  • You can also create patches and apply patches.

Q. What are the differences between trunk, branch, and a tag in relation to a source control system like SVN?
A. There are many source control systems like Git, Clearcase, Subversion (aka SVN), etc, and SVN is a very popular open source source control system. You can use it via its command line commands or via GUI based client tools like TortosieSVN.

  • A trunk in SVN is main development area, where major development happens. Like a tree, trunk is a tree’s central superstructure. All branches come out of the trunk.
  • A branch in SVN is sub development area where parallel development on different features happens. Branches are created for adding new features/enhancements, bug fixes, and maintenance. After completion of a functionality, a branch is usually merged back into trunk. Tools like TortoiseSVN and IDE plugins for SVN simplifies the code merging task.
  • A tag in SVN is a read only copy of source code from branch or trunk at any point of time. A tag is mostly used to create a copy of released source code so that it can be rolled back.
  • A head is the latest version in the repository. That is either in the trunk or branch.

Q. What are the basic steps involved in merging? for example from a branch to trunk.
A

  • Step 1: Check out the destination stream from SVN. In this case it is the trunk.
  • Step 2: The SVN client tools like tortoiseSVN or Eclipse IDE plugin provides you with a GUI interface to select the source code to merge. In this case it is the branch. Click on the merge button to merge automatically, and where there are conflicts, you need to merge those conflicts manually. You can also use the SVN command-line option.
  • Step 3: Test the merged code locally to ensure that they compile and work as expected.
  • Step 4: Check in the merged code into the destination. In this case the trunk.

Q. What do you understand by the term rebase?
A. When developers work in parallel and commit changes to different streams of the same code base, eventually some or all of these commits have to be brought together into a shared graph, and merging and rebasing are two primary ways that let us do that.

  • Merging brings two lines of development together while preserving the ancestry of each commit history. It is like melting two different pipes  together. The pipe itself doesn’t break, it’s just combined with another pipe. So, the commit itself knows that it is a merge commit.
  • In contrast, rebasing  is like cutting off a pipe and weld it on another pipe. Rebasing unifies the lines of development by re-writing changes from the source branch so that they appear as children of the destination branch – effectively pretending that those commits were written on top of the destination branch all along.

Q. What is a sync merge and when do you perform it?
A. Say you create a new branch from a head to work some enhancements, and simultaneously some bug fixes were made on the trunk. Suppose that a month has passed since you started working on your new branch and your new feature are not finished yet, but at the same time you know that other people on your team continue to make important bug fixes on the trunk. Its in your best interest to replicate those changes to your own branch, just to make sure that they integrate well with your changes. This is done by performing a sync merge, which is a merge operation designed to bring your branch up to date with any changes made to its ancestral parent, which is the trunk in this case. The sync merge is also known as rebasing.

Q. What do you understand by the term patch or pull request?
A.A patch means change sets you want to communicate and apply to another repository. Nowadays, the GitHub pull request makes it really easy to apply patches on GitHub repos, which is useful when you arent a direct contributor. A patch is a small file that indicates what was changed in a repository. Its generally used when someone from outside your team has read-only access but had a good code change available. He then creates a patch and sends it to you. You apply it and push it to the git repository. Here is a simple example.

Create an input file named "input.txt" as shown below and check in to the repository like SVN.

  
This is line A.
This is line B.


Now modify the above code as shown below by replacing A in first line to C.

  
This is line C.
This is line B.


Now create a patch file, for example from eclipse IDE using the SVN plugin by right clicking on the file and then select Team --> Create patch. The patch file created will be

  

Index: src/test/resources/input.txt
===================================================================
--- src/test/resources/input.txt (revision 19063)
+++ src/test/resources/input.txt (working copy)
@@ -1,2 +1,2 @@
-This is line A.
+This is line C.
This is line B.
No newline at end of file


The above patch tells that

@@ -1,2 +1,2 @@ tells that in line 1 was removed and another line 1 was added and line 2 remains the same. The "-" next to "-This is line A." indicates that this line was removed. The "+" sign next to "+This is line C." indicates that this line was added. You will also get similar patch output with a Unix diff tool.

 
$ diff -u input.txt output.txt


Note: For beginners, it can be a bit overwhelming to understand version control system, and the following blog explains things visually.
Read More..

DFI Blood Iron P45 P45 T2RS

DFI Blood Iron P45 P45-T2RSDFI Blood Iron P45 P45-T2RS Elite motherboard is a DFI motherboard product which is a refinement of the initial version of this product.

Some improvement is made in the PCB design, the use of CHIP for network and this product supports the use of processor Intel Core 2 Duo and Quad with FSB 1333 MHz.

DFI Blood Iron P45 P45-T2RS Elite suitable to be used by overclockers even this product claimed capable of overclocking processor with 600 MHz FSB reached.

Motherboard with the estimated maximum capacity will be present with the price below the average.

More info@vr-zone.com




Bookmark and Share
Read More..

How to get environment variables in Java Example Tutorial

Environment variables in Java
There are two ways to get environment variable in Java, by using System properties or by using System.getEnv(). System properties provides only limited set of predefined environment variables like java.classpath, for retrieving Java Classpath or java.username  to get User Id which is used to run Java program etc but a more robust and platform independent way of getting environment variable in Java program on the other hand System.getEnv() method provide access to all environment variables inside Java program but subject to introduce platform dependency if program relies on a particular environment variable. System.getEnv() is overloaded method in Java API and if invoked without parameter it returns an unmodifiable String map which contains all environment variables and there values available to this Java process while System.getEnv(String name) returns value of environment variable if exists or null. In our earlier posts we have seen How to get current directory in Java and  How to run shell command from Java program and in this Java tutorial we will see how to access environment variable in Java.

How to get environment variables in Java - Example

How to get value of environment variable in Java - example tutorialHere is a quick example on How to get environment variable in Java using System.getEnv() and System.getProperty(). Remember System.getEnv() return String map of all environment variables while System.getEnv(String name) only return value of named environment variable like JAVA_HOME will return PATH of your JDK installation directory.

/**
 * Java program to demonstrate How to get value of environment variables in Java.
 * Dont confuse between System property and Environment variable and there is separate
 * way to get value of System property than environment variable in Java, as shown in this
 * example.
 *
 * @author Javin Paul
 */


public class EnvironmentVariableDemo {  

    public static void main(String args[]){
   
      //getting username using System.getProperty in Java
       String user = System.getProperty("user.name") ;
       System.out.println("Username using system property: "  + user);
   
     //getting username as environment variable in java, only works in windows
       String userWindows = System.getenv("USERNAME");
       System.out.println("Username using environment variable in windows : "  + userWindows);
   
     
     //name and value of all environment variable in Java  program
      Map<String, String> env = System.getenv();
        for (String envName : env.keySet()) {
            System.out.format("%s=%s%n", envName, env.get(envName));
        }

    }
     
}

Output:
Username using system property: harry
Username using environment variable in windows : harry
USERPROFILE=C:Documents and Settingsharry
JAVA_HOME=C:Program FilesJavajdk1.6.0_20
TEMP=C:DOCUME~1harryLOCALS~1Temp


Getting environment variable in Java – Things to remember
Java is platform independent language but there are many things which can make a Java program platform dependent e.g. using a native library. Since environment variables also vary from one platform to another e.g. from windows to Unix you need to be bit careful while directly accessing environment variable inside Java program. Here are few points which is worth noting :

1) Use system properties if value of environment variable is available via system property e.g. Username which is available using "user.name" system property. If you access it using environment variable directly you may need to ask for different variable as it may be different in Windows  e.g. USERNAME and Unix as USER.

2) Environment variables are case sensitive in Unix while case insensitive in Windows so relying on that can again make your Java program platform dependent.

3) System.getEnv() was deprecated in release JDK 1.3 in support of using System.getProperty() but reinstated again in JDK 1.5.

Thats all on how to get environment variable in Java. Though you have convenient method like System.getEnv() which can return value of environment variable, its better to use System.getProperty() to get that value in a platform independent way, if that environment variable is available as system property in Java.

Other How to tutorials from Javarevisited Blog
Read More..