Thursday, 4 June 2015

Code recipe: Using Maven to launch a Java Process

GET JAVA & MAVEN

apt-get maven2
apt-get java

GET YOUR PROJECT

git init <repo> cd <repo> git remote add -f origin <url>
git config core.sparseCheckout true

echo "some/dir/" >> .git/info/sparse-checkout
echo "another/sub/tree" >> .git/info/sparse-checkout
git pull origin master
mvn clean compile
mvn exec:java
(With a setting in the project "exec.mainClass")


yes!



nohup mvn exec:java &


Thursday, 21 May 2015

Cool tool of the day:

Why is my Eclipse so Slow?
Optimizer for Eclipse

As much as many devs will say that eclipse is the best IDE, it still sucks when it comes to starting up.
Luna is an improvement over some of the earlier versions but it can still leave you waiting for it to start.

This is a topic I have visited before (Setting up Eclipse check list (Part 1)Eclipse Configuration settings) but now comes "Optimizer for Eclipse". A plugin by  Zeroturnaround (the people who brought us JRebel) so it has an impressive pedigree.

The plugin works by tuning the startup settings for eclipse. Again this can be done by hunting these settings down but its nice to have them all in one place.
Once installed it prompts you to select a number of options, restarts eclipse and tells you if you saved any time. It then disappears to site under the Help menu.

On my first use of it I turned off class validation and found that Eclipse started 1 full minute faster.

So I'm pleased!

How to install

Either install using:
  • Marketplace
    Open Help → Eclipse Marketplace…
    Search for Optimizer for Eclipse.
    Press Install.
  • Update site
    Open Help → Install New Software…
    Add this repository.
    Complete the plugin installation.

Wednesday, 8 April 2015

Cool tool of the day: jsonschema2pojo

So we all love JSON?

AND I love Java but creating the Java classes to serve or parse your JSON is a pain.

Especially when the JSON alters!

So use jsonschema2pojo!

It comes with a handy code generator Maven plugin.

The steps are as follows:

  1. Create a Java project with a maven POM;
  2. Add the code generator as seen in the documentation;
  3. Capture your JSON;
  4. Create the JSON schema in the folder specified in your POM using jsonschema.net;
  5. run mvn generate-sources;
Done!

Tuesday, 31 March 2015

How to Tune Java Garbage Collection

How to Tune Java Garbage Collection

This is an excelent and very clear article on Java JVM tuning.

Think about the fundamental cause of GC tuning. The Garbage Collector clears an object created in Java. The number of objects necessary to be cleared by the garbage collector as well as the number of GCs to be executed depend on the number of objects which have been created. Therefore, to control the GC performed by your system, you should, first, decrease the number of objects created.
 The following table shows options related to memory size among the GC options that can affect performance.
Table 1: JVM Options to Be Checked for GC Tuning.
ClassificationOptionDescription
Heap area size-XmsHeap area size when starting JVM
-XmxMaximum heap area size
New area size-XX:NewRatioRatio of New area and Old area
-XX:NewSizeNew area size
-XX:SurvivorRatioRatio of Eden area and Survivor area
I frequently use -Xms-Xmx, and -XX:NewRatio options for GC tuning.  -Xms and -Xmx option are particularly required. How you set the NewRatio option makes a significant difference on GC performance.Some people ask how to set the Perm area size? You can set the Perm area size with the-XX:PermSize and -XX:MaxPermSize options but only when OutOfMemoryError occurs and the cause is the Perm area size.


The full article can be founs at : http://www.cubrid.org/blog/dev-platform/how-to-tune-java-garbage-collection/

Slides on HTTP authentication methods

HTTP authentication methods

These are as usefull set of slides on Http authentication.

Click to view "HTTP authentication methods"

See: http://talks.codegram.com/http-authentication-methods

Monday, 30 March 2015

Cool tool of the day: zapier

According to its website zapier does the following:
Unlock the Hidden Power of Your Apps
Zapier connects the web apps you use to easily move your data and automate tedious tasks.
I've used this tool to move data between PivotalTracker and JIRA and found that it was very, very easy to set up.
The cost of this service (https://zapier.com/app/pricing)  rins from $0 to $125/month which compared to development costs is epic.
The variety of services that can take information from one place to another is truley epic (https://zapier.com/zapbook/).
Considering this tool can take information from places such as Amazon SQS and Amazon RDS the scope for setting up easy process creation is huge!

I will return to this blog post at a later date.

But until then their promo vid ...

Friday, 27 March 2015

Issue with Cordova 4.3.0 behind a corporate firewall & Proxy

While working with npm and cordova I have encountered an issue with Cordova when running it behind our corporate firewall & proxy.
Initially we thought the issue was related to the issue described here: http://wil.boayue.com/blog/2013/06/14/using-npm-behind-a-proxy/.
But we discover that while npm could be fixed as described here this didn’t fix Cordova.

We have configured npm to point at our Sonatype repository but we discovered that Cordova does not pick up the ‘registry’ setting from npm as it has the registry hard coded in several places.
ie.  In lazy_load.js

Line #148 is the original line which we have had to modify with line #149.


This issue manifests when we do a “cordova platform add ios” for example.

You can go throught all the js files and replace all the lines where it occurs but only lazy_load.js seemed to be the problem.

I would also update the 'version' entry in your cordova package.json file as well to ensure that you know you have patched your instalation.

See: https://stackoverflow.com/questions/29306422/issue-with-cordova-4-3-0-behind-a-corporate-firewall