View RSS Feed

My Java Tips

  1. Eclipse project - Extension page

    by , 11-17-2011 at 06:16 PM (My Java Tips)
    Extensions are the central mechanism for contributing behavior to the platform. Unless your plug-in is a simple Java API library made available to other plug-ins, new behavior is contributed as an extension.


    The Extensions page is where you can add, remove and modify the extensions your plug-in contributes to the platform.


    Each extension point comes with an xml schema specifying ...
    Categories
    Eclipse
  2. Eclipse Plugin Project - Extension Points

    by , 11-17-2011 at 06:08 PM (My Java Tips)
    Extension points define new function points for the platform that other plug-ins can plug into.


    The Extension Points page is the place to add, remove and edit extension point declared by your plug-in.


    An extension point has three attributes:

    - id - a required attribute whose value is a simple name
    - name - a required attribute whose value is a translatable ...
  3. Plugin project - Build configuration page

    by , 11-17-2011 at 06:02 PM (My Java Tips)
    The Build Configuration page contains all the information needed to build, package and export the plug-in. It appears as a page in the plug-in manifest editor, but note that changes made to it will be written by PDE to the build.properties file of the plug-in. This file solely guides the build process.




    The Runtime Information section lists all the libraries that you want to build. For ...
  4. Eclipse Plugin Project - Source pages

    by , 11-17-2011 at 05:59 PM (My Java Tips)
    This post is about the source pages of Eclipse plugin project.


    Following are the points of interest:

    - The plug-in editor manages all three plug-in files at the same time.

    - The manifest.mf file is where all the plug-in data and dependencies is stored.

    Review the next part of this post.
    The plugin.xml file contains the extensions and extension points declared ...
  5. Running a plug-in

    by , 11-16-2011 at 07:38 PM (My Java Tips)
    As you develop your plug-in in the workspace, the incremental Java compiler will compile your Java source code and place the .class files into the bin directory of your PDE project. When you are ready to test your plug-in, you can launch a separate Eclipse application instance to test your new plug-in.


    The easiest way to launch an Eclipse application is via the link in the Testing section of the plug-in manifest editor's Overview page. This will immediately create a second Eclipse ...
  6. Java performance Issues

    by , 11-16-2011 at 07:17 PM (My Java Tips)
    In this post, I will talk about Java performance Issues briefly.


    General

    The output of a Java compiler is a bytecode and not an executable code. The Java Virtual Machine (JVM) interprets the Java bytecode at runtime. Most of the modern programming languages such as C, C++ are not interpreted and compiled to the executable code because of the performance concern. When a program is interpreted, it generally executes slowly when compared with an executable code.
    ...
  7. Struts Action Class

    by , 11-15-2011 at 06:39 PM (My Java Tips)
    In this article let us see how to use Struts Action Class and forward a jsp file through it.



    Introduction

    An Action class in the struts application extends Struts 'org.apache.struts.action.Action" Class. Action class acts as wrapper around the business logic and provides an interface to the application's Model layer. It acts as glue between the View and Model layer. It also transfers the data from the view layer to the specific business process layer and ...
  8. Sending files from Servlet

    by , 11-15-2011 at 06:35 PM (My Java Tips)
    In this post, I will present an example which will show how to move the selected file (drop down menu) form a servlet to another servlet which performs operations on the file.


    I have created 3 Javafiles namely:

    - HelloServlet(Servlet)
    - GetImg (Servlet)
    - ImgCompare (simpleJava class)

    HelloServlet contains a HTML form that has a dropdown menu. Menu contains 2 JPG files. You should have following images at the given path:

    C:\image1.jpg ...
    Categories
    Java EE
  9. Java Generics with legacy code

    by , 11-15-2011 at 06:31 PM (My Java Tips)
    In this post, I will write about how Java generics help us in using legacy code.


    Generics are new in Java and now developers understand the importance of it and it is being used as required. Question arises, what about the legacy code? Consider an IT firm that is working on an application for 5 years, and they used Java 1.4 for development. They the plan to use 1.5 for development simply because it is better than 1.4. Are they supposed to convert the old code to 1.5 also? This is ...
  10. Using tags in Struts

    by , 11-15-2011 at 06:26 PM (My Java Tips)
    Web applications differ from conventional websites in that web applications can create a dynamic response. To make it easier to reference dynamic data from a page, the Struts framework offers a set of tags. Some of the tags mimic standard HTML tag while providing added value. Other tags create non-standard, but useful controls. While HTML provides a simple a tag for creating hyperlinks, the HTML tag often requires us to include redundant information. Also the HTML tag cannot easily access dynamic ...
    Categories
    Struts
  11. Struts”Hello World”

    by , 11-15-2011 at 06:15 PM (My Java Tips)
    Lets make a HelloWorld example using Struts.


    Suppose you want to create a simple "Hello World" example that displays a welcome message. To create a "Hello World" example, you need to do three things:

    1. Create a server page HelloWorld.jsp to present the messages

    Java Code:
    <%@ taglib prefix="s" uri="/struts-tags" %>
    <h2><s:property value="message"></s:property></h2>
    ...

    Updated 11-15-2011 at 06:21 PM by Java Tip

    Categories
    Struts
  12. Setup a Struts 2 application

    by , 11-15-2011 at 06:08 PM (My Java Tips)
    in this post, I will write about how to setup a Struts 2 application from scratch. This will be interesting for the developer who are using Struts for the very first time.


    Download the latest struts framework from the http://struts.apache.org. To get started with a new application you can setup a web infrastructure from scratch.

    Setup the Web Application File Structure as follows within webapps folder. (This tutorial assumes that you are using Apache Tomcat as a web ...
  13. Apache Struts

    by , 11-15-2011 at 06:03 PM (My Java Tips)
    Apache Struts is a free open-source framework for creating Java web applications. In this post, I will write about Apache Struts.


    In a standard Java EE web application, the client will typically submit information to the server via a web form. The information is then either handed over to a Java Servlet which processes it, interacts with a database and produces an HTML-formatted response, or it is given to a JavaServer Pages (JSP) document which intermingles HTML and Java code to ...
  14. Introduction to Model View Controller Architecture

    by , 11-14-2011 at 05:51 PM (My Java Tips)
    Designing large sized enterprise applications is a difficult task because the code maintenance becomes difficult as the size of application goes. Model View Controller Architecture presents a solution to this. In this post, I will introduce you to MVC.


    Web applications based on JavaServer Pages sometimes mix database code, page design code, and control flow code. In practice, we find that unless these concerns are separated, larger applications become difficult to maintain. One way ...

    Updated 11-14-2011 at 05:57 PM by Java Tip

    Categories
    MVC
  15. Capture screenshots

    by , 11-14-2011 at 05:41 PM (My Java Tips)
    Taking screenshots in windows is simple and very useful in our day to day business. It is done by pressing the Print Screen key on your keyboard [PrtScn], pasting it in image editor such as MS paint and then editing and saving it. In this post, I will write about how to do this from Java program.


    Java provides classes to help us which capturing screens.

    java.awt.Robot is used to generate native system input events which can be used to for test automation, and other ...
  16. Changing Java for projects

    by , 11-14-2011 at 05:37 PM (My Java Tips)
    Sometimes you want to keep legacy code and for that you have to use older version of Java. These days, people are working in Java 5 and Java 6. But still developers are using legacy code which means using Java 1.3 and Java 1.4. In this post, I will brief you how to change the Java version for projects in Eclipse.


    Eclipse provides support for changing the Java version through few clicks. Eclipse 3.3.0 has Java 5.0 configured. So if you do not specify Java version, your project will ...
    Categories
    Eclipse
  17. Changing Console properties

    by , 11-14-2011 at 05:31 PM (My Java Tips)
    Eclipse provides a console window in which you see the output of your Java program. Normally default properties are sufficient and developers are satisfied with it. In some cases, you might want to change the look and feel of the console window. I'll write about this in this post.


    The default console looks like this:


    Now lets try to change the look and feel. Click
    ...
    Tags: console, eclipse Add / Edit Tags
    Categories
    Eclipse
  18. Generating Interface from a Class

    by , 11-14-2011 at 05:27 PM (My Java Tips)
    Some times you have a class with concrete methods and you want to declare an interface with all the methods in the class. You may call it backtracking. In this post, I will write about how to do this in Eclipse.


    Suppose we have a class called Students that has methods defined in it. We want to generate the interface for it in Eclipse. Simply right click the class name, or simply right click anywhere in the code and select Refactor > Extract interface. A new window will open. Name ...
  19. Viewing Outline of a Class

    by , 11-14-2011 at 05:20 PM (My Java Tips)
    Eclipse includes a useful feature called outline. It helps the developer to get a birds eyes view of the class. In this post, I will explore it.


    You can display outline panel of your class by Navigate > Show in > Outline.

    Eclipse Outline



    Outline will show all the methods and fields in the class. It used special symbols for private, public, static fields ...
    Tags: eclipse, outline Add / Edit Tags
    Categories
    Eclipse
  20. Build a Rich Client Platform application

    by , 11-14-2011 at 04:54 PM (My Java Tips)
    While the Eclipse platform is designed to serve as an open tools platform, it is architect so that its components could be used to build just about any client application. The minimal set of plug-ins needed to build a rich client application is collectively known as the Rich Client Platform.

    Applications that don't require a common resource model can be built using a subset of the platform. These rich applications are still based on a dynamic plug-in model, and the UI is built using ...
    Categories
    RCP
  21. RCP Custom Look and Feel

    by , 11-14-2011 at 04:40 PM (My Java Tips)
    The presentation of your Rich Client Platform application can be changed using the org.eclipse.ui.presentationFactories extension point.


    This example will show how to use the R2.1 presentation, provided by the org.eclipse.ui.presentations.r21 plugin, in the RCP Browser Example application. Here is a screen shot of the browser example using the R2.1 presentation.




    ...
  22. Eclipse RCP Browser Example

    by , 11-14-2011 at 04:33 PM (My Java Tips)
    Description

    This is an example of a simple Eclipse Rich Client Platform (RCP) application. It is a bare bones web browser, using the SWT Browser control.


    To load the browser example source into your workspace, load project org.eclipse.ui.examples.rcp.browser from the Eclipse CVS repository.

    The code is in package org.eclipse.ui.examples.browser, and consists of an application class (BrowserApp), a workbench advisor for configuring the workbench (BrowserAdvisor), ...
    Categories
    RCP
  23. Defining a rich client application

    by , 11-13-2011 at 05:50 PM (My Java Tips)
    The definition of a rich client application plug-in starts out similarly to the other plug-ins we've been studying. The only difference in the first part of the markup is that the list of required plug-ins is much smaller than we've been used to.


    XML Code:
    <!--?xml version="1.0" encoding="UTF-8"?-->
    <!--?eclipse version="3.0"?-->
    <plugin
       id="org.eclipse.ui.examples.rcp.browser"
       name="%pluginName"
    ...
  24. Rich Client Platform (introduction)

    by , 11-13-2011 at 05:37 PM (My Java Tips)
    The Eclipse Rich Client Platform (RCP) allows developers to use the Eclipse architecture to design flexible and extensible applications re-using a lot of already existing functionality and coding patterns inherent in Eclipse. Programmers can build their own applications on existing platforms. Instead of having to write a complete application from scratch, they can benefit from proven and tested features of the framework provided by the platform. Building on a platform facilitates faster application ...
    Categories
    RCP
  25. Vector Capacity

    by , 11-13-2011 at 11:48 AM (My Java Tips)
    In this post, I will talk about the performance issues related to vector capacity. I have noticed, that normally developers don’t care about the performance issues and declare the vector as:

    Java Code:
    Vector vector = new Vector();


    Newly created vector has no element in it so its size is 0 but its capacity is 10 by default. So if you don’t specify the capacity of the vector (and call the default constructor), its capacity will be 10. Capacity of the vector is the ...
    Tags: capacity, vector Add / Edit Tags
    Categories
    Performance
  26. Bounding ArrayList

    by , 11-13-2011 at 11:45 AM (My Java Tips)
    Collections can be of a particular type i.e they are only allowed to hold objects of a defined type. This is called “bounded by”. For example:

    Java Code:
    ArrayList  arrayList  = new  ArrayList();
    Vector  vector  = new  Vector();


    We declared an ArrayList and a Vector both bounded by String. We cannot store objects other than String in these. Lets try to store an integer in Vector and see what happens.

    Java Code:
    Vector  vector  = new  Vector();
    ...
  27. Interface extending Interface

    by , 11-13-2011 at 11:42 AM (My Java Tips)
    An interface can extend other interface but cannot implement any interface. This makes sense because interface cannot have any implementation. An interface can only contain abstract methods that are implemented by the class implementing that interface.


    Lets do this with an example.

    Create a package named myinterfaces. Using conventions, package name should be in small case. Now create an interface named InterfaceA with 2 methods.

    Java Code:
    package myinterfaces;
    ...
  28. Using LinkedList (Collection)

    by , 11-13-2011 at 11:40 AM (My Java Tips)
    LinkedList is a special type of List which is very useful in certain scenarios. Some important facts about LinkedList are:
    - It is not synchronized
    - It does not use array internally for storage
    - It uses pointers internally to point to next node
    - It implements Cloneable, List and Serializable interfaces


    LinkedList is preferred when you know that you have to add and delete data from the start or from middle of the list. It perform addition and deletion ...
    Categories
    Java SE
  29. Implementing more than one Interfaces

    by , 11-13-2011 at 11:37 AM (My Java Tips)
    Interfaces contain abstract methods that implementing class has to implement. It is must for the implementing class to implement all the methods found in the interface. Sometimes you face a situation where you have to implement more than one interface. How to do that?


    One way is to simply try to write one interface with all the abstract methods. This is not at all flexible as all of these interfaces might be used in different scenarios. So its better to keep each as a separate interface. ...
  30. Constructor calling ordering

    by , 11-13-2011 at 11:34 AM (My Java Tips)
    Constructors are used for initialization normally. Name of constructor should be same as that of the class. If no constructor is declared, a default constructor is created without parameters. Constructor does not return any thing.


    Consider the example below. ClassB inherits from ClassA. In the MainClass, we made an object of ClassB. Default constructor will be called. But the output suggests that first Constructor of ClassA is called and then the constructor of classB is called. ...
Page 4 of 15 FirstFirst ... 2345614 ... LastLast