Tuesday, May 6, 2014

Eclipse is too slow, they try out these options

Are you feeling your eclipse is slow ? And, is it taking lot of time to open your eclipse ?

Based upon my experience I have put down some points that would help you out.

1.       Try to open your eclipse in clean mode.
    Command:  > eclipse –clean

What is does ?
Cached data used by the OSGi framework and eclipse runtime will be wiped clean. This will clean the caches used to store bundle dependency resolution and eclipse extension registry data. Using this option will force eclipse to reinitialize these caches.

http://www.eclipsezone.com/eclipse/forums/t61566.html

2.       Configuring suitable heap memory size in eclipse.ini file. Verify max heap size parameter (Xmx) and configure based on the application need.
Example:  -Xmx1024M

This is where your java objects will be stored.

3.       Make sure to configure sufficient permgen size in eclipse.ini file. Configure based on the your application need.
  
 Example: -
-XX:PermSize=256m
-XX:MaxPermSize=512m

This is where you classes and method definitions will be loaded after starting your application

4.       Close unnecessary projects in your workspace.
Example: You might have 10 plug-ins in your eclipse current workspace, but you might be using or working on only 2 plug-ins, and that work independent of other plug-ins.

5.       Try to avoid force closing eclipse.  It takes lot of time to initialize the previous state of eclipse based on the history indexes.

6.       Don't enable all third-party code enforcement tools by default.

Example:
  • Find bugs - run based upon need.
  • Google code analytics
  • Check style

 7.       You can remove Project build automatically option in eclipse and enable only based on the need.

8.  Remove automatic updates for eclipse plug-ins and third party plug-ins.
    You can find “Automatically find new updates and notify me” option in your eclipse.

8.       Once in a while try to switch all your plug-ins/projects in to new workspace and work.


As a programmer:
  • Don't keep so much of code in your Activator start() methods
  • Minimize the number of classes in the each plug-in
  • Don't run too many background processes in your application.
  • Don't create too many threads at a time. Make sure no.of threads should be less than or equal to number of processor cores in the system.


java.lang.UnsatisfiedLinkError: Cannot load 32-bit SWT libraries on 64-bit JVM


This problem occurs when we are trying to load 32 bit swt libraries (ex: swt.jar) on 64 bit Java

Example: When you are trying to open your 32 bit eclipse with 64 bit JRE, you will be facing this issue.

Another case would be, you would have packaged 32 bit swt libraries with your application, but you are trying to run your application on 64 bit JRE.

How to resolve ?
Make sure you will be using the same version either 32 bit/64 bit for eclipse and Java.


Error:
java.lang.UnsatisfiedLinkError: Cannot load 32-bit SWT libraries on 64-bit JVM
at org.eclipse.swt.internal.Library.loadLibrary(Library.java:197)
at org.eclipse.swt.internal.Library.loadLibrary(Library.java:174)
at org.eclipse.swt.internal.C.<clinit>(C.java:21)
at org.eclipse.swt.widgets.Display.<clinit>(Display.java:138)
at org.eclipse.ui.internal.Workbench.createDisplay(Workbench.java:687)
at org.eclipse.ui.PlatformUI.createDisplay(PlatformUI.java:161)
at org.eclipse.ui.internal.ide.application.IDEApplication.createDisplay(IDEApplication.java:145)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:88)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:620)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:575)
at org.eclipse.equinox.launcher.Main.run(Main.java:1408)
at org.eclipse.equinox.launcher.Main.main(Main.java:1384)

Finding a .log file in eclipse

Your .log file is located in a .metadata folder in your current workspace directory.
The following is the path if you are working on the default workspace.

Example:

Windows : C:\Users\username\Documents\<Studio Workspace>\.metadata\.log

Mac OS X: ~/Documents/<Studio Workspace>/.metadata/.log


Wednesday, April 30, 2014

Wednesday, April 16, 2014

Writing git log output to a file

Example:
$ git log --since="04/07/2014 20:37:53" --no-merges  > C:\test.log

It will write generated git log from the specified date and time without including merges to a test.log file.

Monday, April 7, 2014

Creating an executable JAR file for SWT Plug-in - Runnable JAR

You would have developed a small utility application, and now you wanted to create an executable JAR for that application.
Basically, end user should be able to launch the application by just double clicking on that.

Eclipse provides an option called “Runnable JAR” in the export menu items to perform this.






This will generate Plugin_Refactor_x86_1.0.jar file, including with all the required swt jars. 

Since swt native jars will be platform specific, we need to generate 32 bit or 64 bit files separately.

How to check Installed Java is a 32 bit or 64 bit version ?


If you have installed JDK, Java would have registered in the system environment variables.

Go to command prompt and type “java –version”

C:\Users\kh1205>java -version
 java version "1.6.0_30"
Java(TM) SE Runtime Environment (build 1.6.0_30-b12)
Java HotSpot(TM) 64-Bit Server VM (build 20.5-b03, mixed mode)

If it’s a 64 bit Java, you will be finding “64-Bit Server VM” in the above line.

If it’s a 32 bit java, you will be finding “Client VM” in the above line.

I have another JDK configured in my system, for which I wanted to check java version.
For example, other version of java is available in the location “C:\Program Files (x86)\Java\jdk1.6.0_31

C:\Program Files (x86)\Java\jdk1.6.0_31\bin>java -version
 java version "1.6.0_31"
Java(TM) SE Runtime Environment (build 1.6.0_31-b05)
Java HotSpot(TM) Client VM (build 20.6-b01, mixed mode, sharing)


“Client VM” in the last line tell you that,  JDK is a 32 bit version.