Tuesday, April 16, 2013

Your eclipse is 32 or 64 bit ??



How can I find out if a specific Eclipse instance on my (Windows 7) PC is the 32-bit or 64-bit version?

Windows Task Manager Dialog:
Hit ctrl-alt-delete, open up task manager - look at the processes tab. 32-bit programs should be marked with a *32

eclipse.ini file:
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.2.R36x_v20101222

And also you can find in
Eclipse SDK Installation Details:> Configuration page

Monday, April 15, 2013

Order of Tags in Java comments




Order of Tags
Include tags in the following order:
  • @author (classes and interfaces only, required)
  • @version (classes and interfaces only, required.)
  • @param (methods and constructors only)
  • @return (methods only)
  • @exception (@throws is a synonym added in Javadoc 1.2)
  • @see
  • @since
  • @serial (or @serialField or @serialData)
  • @deprecated 

Tuesday, April 2, 2013

GIT: showing only list of modified files in a commit


git show --pretty="format:" --name-only  6773e94744fd6885f0737655e491f075afb8c80a

Output:

trunk/guieditor/src/com/pat/tool/keditor/editors/SAPServerDetailsDialog.java
trunk/guieditor/src/com/pat/tool/service/model/SAPServer.java
trunk/guieditor/src/com/pat/tool/service/model/SAPServerUtil.java

Tuesday, March 26, 2013

The protocol of IProgressMonitor


Very nice write-up on this:
http://www.eclipse.org/articles/Article-Progress-Monitors/article.html
http://www.eclipse.org/articles/Article-Progress-Monitors/article.html#Ensure_to_always_complete_your_monitor


One contract pattern described above is that if beginTask() is ever called, done() MUST be called. This is achieved by always following this code pattern (all code is simplified):
monitor = … // somehow get a new progress monitor which is in a pristine state
// figure some things out such as number of items to process etc…
try
 {
 monitor.beginTask(…)
 // do stuff and call worked() for each item worked on, and check for cancellation
 }
finally
 {
 monitor.done()
 }

Tuesday, March 19, 2013

Javascript functions and difference



The two ways to declare a java script function:
var functionOne = function() {
    // Some code
};
function functionTwo() {
    // Some code
}


The difference is that functionTwo is defined at parse-time for a script block, whereas functionOneis defined at run-time. For example:
<script>
  // Error
  functionOne();

  var functionOne = function() {
  }
</script>

<script>
  // No error
  functionTwo();

  function functionTwo() {
  }
</script>




Tuesday, February 26, 2013

StringBuilder with modern compilers



Modern Java compiler convert your + operations by StrinBuilder's append. I mean to say if you do str = str1+sr2+str3 then compiler will generate following code
StringBuilder sb = new StringBuilder();
str = sb.append(str1).append(str2).append(str3).toString();
So now its more of matter of choice than performance benefit to use + or StringBuilder :)

JVM: Finding the process id


package com.kk.memory.tool;

import sun.management.VMManagement;
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.lang.reflect.Field;
import java.lang.reflect.Method;

public class FindJavaProcessId {

public static void main(String[] args) {

try {
RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
Field jvmField = runtimeMXBean.getClass().getDeclaredField("jvm");
jvmField.setAccessible(true);
VMManagement vmManagement = (VMManagement) jvmField.get(runtimeMXBean);
Method getProcessIdMethod = vmManagement.getClass().getDeclaredMethod("getProcessId");
getProcessIdMethod.setAccessible(true);
Integer processId = (Integer) getProcessIdMethod.invoke(vmManagement);
System.out.println("################    ProcessId = " + processId);
} catch (Exception e) {
e.printStackTrace();
}
}

}