NetBeans Tips

Use Eclipse Shortcuts
Tools -> Options -> Keymap -> select Eclipse profile
Create code template
Tools -> Options -> Editor -> "Code Templates"
Press tab to activate define code template.
Reset the layout of windows
Windows -> Reset windows
Float/Dock views
Export/Import Settings
Open Options Dialog: Tools > Options
Click Export/Import button

In NetBeans, we can run a project, run a file, or run a test file.
Select project -> Properties -> Choose Run node -> Type command line arguments in the Arguments text box.
Remote debug
Settings in Netbeans:
Debug -> Attach Debugger
In the "Attach" dialog:
Debugger:  JPDA
Connector: Socket Attach
Transport: dt_socket
Enter host and port
Settings in server:
set JAVA_OPTS=%JAVA_OPTS% -Xrunjdwp:transport=dt_socket,address=9999,server=y,suspend=n
Update Sites

Additional Development Plugins
Latest Development Build
Static Development UC
Dynamic Development UC
Netbeans logs
Windows XP: C:\Documents and Settings\joe\.netbeans\6.7\var\log\message.log
Linux: /home/joe/.netbeans/6.7/var/log/messages.log
Mac OS X: /Users/joe/.netbeans/6.7/var/log/messages.log

JBoss Tips

Commands -S -b -c default
run.bat –Djboss.server.log.dir=d:/log
Change ports
In jboss 5, in $JBoss\server\default\conf\bindingservice.beans\META-INF\bindings-jboss-beans.xml, change the port offset of PortsDefaultBindings.
<bean name="PortsDefaultBindings"  class="">
     <!-- The port offset -->
     <!-- Set of bindings to which the "offset by X" approach can't be applied -->
To use the port assignments defined by the Ports01Bindings bean, set the jboss.service.binding.set system property to ports-01 when starting the application server.
run -c myconfig2 -Djboss.service.binding.set=ports-01
Configuring logging

The log4j configuration file is located at server/xxx/conf/jboss-log4j.xml.
Defining a rolling log appender
<appender name="FILE">
    <param name="Append" value="true"/>
    <param name="MaxFileSize" value="10MB"/>
    <param name="MaxBackupIndex" value="20"/>
    <param name="Threshold" value="ERROR"/>
Defining logging for your application
You can log your application by adding category entries to the jboss-log4j.xml file.
<appender name="JBIA" ...>
    <param name="File" value="${jboss.server.log.dir}/jbia.log"/>
<category name="org.jbia">
    <priority value="DEBUG"/>
    <appender-ref ref="JBIA" />

Edit the server.xml file. For the default server in the default location, it is ${jboss.home}\server\default\deploy\jbossweb.sar\server.xml.
Uncomment the "Access logger" section. The log file will show up in server/default/log/localhost_access_log.{todays_date}.log

<Valve className="org.apache.catalina.valves.AccessLogValve"
                prefix="localhost_access_log." suffix=".log"
                pattern="common" directory="${jboss.server.log.dir}" 
                resolveHosts="false" />

Configuring startup parameters
Rename run.bat for example to run-old.bat.
Create another run.bat file and put this line to it:
set JAVA_OPTS=%JAVA_OPTS% -Xms512m -Xmx1024m -XX:MaxPermSize=512m
run-old.bat -b -c default
Dump SOAP Messages
For the case that is not easy to model as a simple DFS request, it is useful to enable the SOAP dump.
For client side, set "";
For server side, set "";
In Jboass, put the following line in newly created run.bat:
Enable remote debug
In newly created run.bat:
rem set JAVA_OPTS=%JAVA_OPTS% -Xrunjdwp:transport=dt_socket,address=9999,server=y,suspend=n
Configure apache httpd.conf:

LoadModule proxy_module modules/
LoadModule proxy_balancer_module modules/
LoadModule proxy_ajp_module modules/
<Proxy balancer://mycluster>
Order deny,allow
Allow from all
BalancerMember http://node1.mycluster.lan:8080/ route=node1 timeout=15
BalancerMember http://node2.mycluster.lan:8080/ route=node2 timeout=15
ProxySet stickysession=JSESSIONID|jsessionid
# other values: bybusyness|byrequests|bytraffic
ProxySet lbmethod=bytraffic 
ProxyPass /jmx-console balancer://mycluster/jmx-console 
ProxyPassReverse /jmx-console  http://localhost:9080/jmx-console stickysession=JSESSIONID|jsessionid

Configure JBoss
In jboss, modify {jboss.home}\server\default\deploy\jbossweb.sar\server.xml to configure the jvmRoute for sticky sessions:
<Engine name="jboss.web" defaultHost="localhost" jvmRoute="node1">

Modify {jboss.home}\server\default\deployers\jbossweb.deployer\META-INF\war-deployers-jboss-beans.xml:
<bean name="WebAppClusteringDefaultsDeploye" class="org.jboss.web.tomcat.service.deployers.ClusteringDefaultsDeployer">
  <property name="useJK">true</property>


Useful Notepad++ Tips

Three years ago, after used Notepad++ after some time, I write one article  about NotePad++. Three years later, it's time to give it some update.
Common Settings
Open "Settings" -> "Preferences...".
In "Tab bar" section of General tab, select "Double click to close document" and "Multi-line".
In "Backup/Auto-Completion" tab, enable auto-completion option, and choose "Word completion".
Enable spell-checker
Install Aspell, afterwards enable spell-checker :)
Use "Ctrl+Tab"
Use "Ctrl+Tab" to switch between to you last viewed file, and quickly jump to the file you want.

Useful Plugins:

How to install plugins:
Go to "Plugins" -> "Plugin Manager" -> "Show Plugin Manager", this will bring up the "Plugin Manager" dialog where you can find many available plugins.
File switcher
Usually I opened many files in Notepad++, 20 - 30+, some files I need edit often, or some files I just forget to close. So sometimes, it would be hard to find files I want to edit in Notepad++.
File switcher is just the plugin that we need- It presents a sortable list, and we can type text to filter and find the file we want.

Compare Plugin - show the difference between 2 files.
XML Tools - XML Checker. Can auto-close tags and provides other useful features.
To Format XML:
Go to "Plugins" -> "XML Tools" -> "Pretty print (XML only -with line breaks) - Ctrl+Alt+Shift+B"
Explorer Plugin – a file browser
Speech Plugin
There are many other useful plugins that may meet your needs, please explore them.


Link With Editor in Eclipse

I remembered that in the old versions of eclipse(maybe 3.1), in the package and project explorer, it will show the current java class that is opened in the editor. When I change to another java class, it the explorer will automatically scroll to display the new class.

It seems this feature is gone in later release.
But the fact is that it is hidden - by default disabled, to enable it, you just need toggle the"Link with Editor" button in Package/Project/ or Navigator toolbar.


Use Working Set to group projects in Eclipse

Use Working Set to organize and group related projects visually in Eclipse

Usually, we develop or maintain different projects at same time, each project
has multiple modules, or related projects, such as test or demo projects.

We want to organize related projects visually, so in eclipse, it would look like:

To achieve this in Eclipse:
Create one working set, add related projects into it, and then (important step here), in project(or package) explorer, click the top down button -> "Top level elements" -> choose "Working Sets".



adsense (5) Algorithm (69) Algorithm Series (35) Android (4) ANT (6) bat (8) Become a Better You (4) Big Data (7) Blogger (14) Bugs (4) Cache (5) Chrome (17) Code Example (29) Code Quality (6) Coding Skills (5) Concurrency (4) Database (7) Debug (16) Design (5) Dev Tips (62) Eclipse (32) GAE (4) Git (5) Good Programming Practices (4) Google (27) Guava (7) How to (9) Http Client (8) IDE (6) Interview (88) J2EE (13) J2SE (49) Jackson (4) Java (177) JavaScript (27) JSON (7) Learning code (9) Lesson Learned (6) Linux (22) Lucene-Solr (112) Mac (10) Maven (8) Memory Usage (4) Network (9) Nutch2 (18) OpenNLP (4) Performance (9) PowerShell (11) Problem Solving (11) Programmer Skills (6) regex (5) Review (4) Scala (6) Security (9) Soft Skills (38) Spark (4) Spring (22) System Design (11) Testing (6) Text Mining (14) Tips (12) Tools (24) Troubleshooting (29) UIMA (9) Web Development (19) Windows (21) xml (5)