Personal notes on Java
For other technologies like HTML, CSS, .NET, PHP, etc. check my other blog


Eclispe plugins

  • ResourceBundle Editor: get it on https://github.com/essiembre/eclipse-rbe

Javadoc

  • Adding JDK Javadoc in eclipse.
    When you are coding in Eclipse, press CTRL and click on any core Java class name in your source. Eclipse will now show a screen saying you don't have the sources installed. However, in this screen there is a link saying "Attach source...". Click that link and import the src.zip file from your JDK installation directory (src.zip).
    Sample location: C:\Program Files\Java\jdk1.6.0_37\src.zip 
  • Adding log4j Javadoc
    Like mentioned above, click the "Attach source..." button -> "Add external folder" -> browse to the log4j folder on your system and choose the "\src\main\java\" folder inside it.
    Sample location: C:\apache-log4j-1.2.17\src\main\java
    Preferred way: in eclipse you can define a "user defined library" that defines the jar to import and its source so that you get the Javadoc in Eclipse. Using a library you can re-use it in other projects without needing to define all this stuff for each project.

Web project structure in Eclipse:


  • WebContent.: Regular Web files (HTML, JavaScript, CSS, JSP, images, etc.)
  • WebContent/some-subdirectory: Web files in subdirectory.
  • WebContent/WEB-INF: web.xml (used for servlet mappings)
  • WebContent/WEB-INF/lib: JAR files specific to application.
  • src/(default package): Unpackaged (default package) Java code. Using the default package is generally a bad choice in Web apps.
  • src/somePackage: Java code in somePackage package.



Code templates

Theres a lot of code templates pre-defined in eclipse.
To use them you type a keyword and then press CTRL+SPACE:
    Ex.: type main and then press CTRL+SPACE to generate a main method.
You can check existing or add your own templates in:
    Window->Preferences->Java -> Editor -> Templates
See some tips to create templates here.

Some examples of keywords:
  • main: generates a main method;
  • try (only works inside a method): generates a try catch;
Some templates I like to add:
name pattern
out System.out.println("${cursor}");
todo todo


Sem comentários:

Enviar um comentário