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
-Xdebug
-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n
Update Sites

Additional Development Plugins
Latest Development Build
Static Development UC
Dynamic Development UC
nbpluginportal
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
shutdown.sh -S
run.sh -b 0.0.0.0 -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="org.jboss.services.binding.impl.ServiceBindingSet">
  <constructor>
     <!-- The port offset -->
     <parameter>1000</parameter>
     <!-- Set of bindings to which the "offset by X" approach can't be applied -->
     <parameter><null/></parameter>
  </constructor>
</bean>
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"/>
</appender>
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"/>
</appender>
<category name="org.jbia">
    <priority value="DEBUG"/>
    <appender-ref ref="JBIA" />
</category>

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 0.0.0.0 -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 "com.sun.xml.ws.transport.http.client.HttpTransportPipe.dump=true";
For server side, set "com.sun.xml.ws.transport.http.HttpAdapter.dump=true";
In Jboass, put the following line in newly created run.bat:
set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.xml.ws.transport.http.HttpAdapter.dump=true
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/mod_proxy.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
<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 
</Proxy>
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>
</bean>

Resources:

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.

Resources:

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.



















Resources:

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:
projecta
---projecta-module1
---projecta-module2
---projecta-module3
---projecta-other-modules
projectb
---projectb--related-modules

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".

Resources:

Labels

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