Archive for the ‘Eclipse’ Category

Viewing complete strings while debugging in Eclipse

February 14, 2017

While debugging Java code, Strings in the views “Variables” and “Expressions” show up only till a certain length, after which Eclipse shows “…”. Even after working with eclipse for 10 years it was a new info for me. There is a way to show the complete string.

In the Variables view you can right click on Details pane (the section where the string content is displayed) and select “Max Length…” popup menu. The same length applies to expression inspector popup and few other places. In the max length give 0 and you will see the whole values in the value box.

untitled

Thats it guys, enjoy coding.

PermGen space Exception in Eclipse

April 25, 2014

Well a quick post. Sometimes Eclipse really go nuts and starts throwing this exception for each and every action :

————————–
Unhandled event loop exception
PermGen space
————————–

You can solve this by editing the eclipse.ini file which is residing in the same directory as the eclipse.exe. Towards the end of the file add this line :

-XX:MaxPermSize=128M

You can give whatever space you like such as 256M or 512M. After this restart your eclipse and forget about the PermGen Space Exception. (I Hope So. :P)

For those who are more interested in permGen, The permanent generation (or permgen) was used for class definitions and associated metadata prior to Java 8. Permanent generation was not part of the heap. The permanent generation was removed from Java 8. Originally there was no permanent generation, and objects and classes were stored together in the same area. But as class unloading occurs much more rarely than objects are collected, moving class structures to a specific area allowed significant performance improvements. In short, PermGen is used by the JVM to hold loaded classes.

For More information on Eclipse permGen space Exception read this : More

Happy Coding Guys…

Apache POI Lost Document Summary Information

April 24, 2013

Being working on Intranet projects, lot of my work runs around exporting records into excel and pdf files. For excel exporting mostly we use Apache POI, the awesome tool to deal with Office files. Recently I came around a problem, where after generating the excel file, while trying to open it , it gave error and the log file states : “Lost document summary information.”.

On inspecting my code, I came across these lines :

byte[] b = report.getBytes();

I was using this byte array to flush to the output. In fact this was causing the problem. On detail research I found out that getBytes() method will not give the complete bytes and some of the bytes are lost. Unfortunately those lost bytes are of the summary information, which was causing Excel to throw error. As a workaround, you can do like this, which solved my problem :

ByteArrayOutputStream bos = new ByteArrayOutputStream();
report.write(bos);
byte[] b = bos.toByteArray();

That’s all for now. Happy Coding. 🙂

Debug using Apache Tomcat and Eclipse

May 16, 2011

It is always useful to debug the code in a line by line fashion to track where the code went wrong. Since I am using Apache Tomcat server for development purpose this article deals with enabling debugging on Apache Tomcat with Eclipe IDE.

First we need to set up the Tomcat server to enable debugging. Usually the debugging port used for tomcat is 8000, but you can set to any free port.

1. Open the startup.bat file from Tomcat directory (<Tomcat Installation Directory>/bin/)

2. After the script initializes the command line arguements, most probably towards end of file, add these two lines :

set JPDA_ADDRESS=8000
set JPDA_TRANSPORT=dt_socket

3. Change the line where it calls the EXECUTABLES to :

call “%EXECUTABLE%” jpda start %CMD_LINE_ARGS% (add jdpa start).

Save the file and start the tomcat. Now the first line of the tomcat startup console will show :

Listening for transport dt_socket at address: 8000

At this point your Tomcat server is ready to be run in debug mode. Now do the following steps at Eclipse IDE for debugging in Eclipse.

1. Open one class where you want to put breakpoint and add one breakpoint. (This can be done by clicking on the left margin on the corresponding line.

2. From Run menu, select Debug Configurations

3. From the left side, right click on Remote Java Application and click new

4. Fill out the form appearing. Only thing to take care is the server name should be localhost and port number 8000. This can be changed if you are debugging on a remote server.

5. Click on debug and now the eclipse is running in debug mode.

Now you can run the application and whenever the thread reaches the line, where you have put the breakpoint, it will pause execution. Then you can see the current values of the variables, you can step by step execute the line and so on.

That’s it guys. Happy Coding 🙂

Linking an external folder to Eclipse / Flex Builder Project

December 6, 2010

At times, there may be a need to link some external folder to the source code of our project in Eclipse or Flex Builder project. One common need is to link the output of our java project in Eclipse to the WEB-INF folder of our web server.  Do the following steps for this.

1. Right click on the project -> new -> Folder.

2. In the dialog box shown, click on the Advanced button, if the advanced section is not expanded. This will expand the advanced section in the dialog box.

3.Now check the checkbox with label : “Link to folder in the file system”. This will enable the text box for entering the path and the Browse and Variables button.

4.Now either enter the path to the folder to which you need to link in the text box or select the folder using the “Browse” button.

5. Click Finish.

BINGO!! This will show the new folder in the folder list under the project. The folder will be having a special icon, denoting that this is a external linked folder. This folder can then be used as source folder or output folder using the Configure Build Path options.

Happy Coding Guyz… Cheers. 🙂

Redirecting the Eclipse/Flex Builder Console output to a log file

August 17, 2010

Usually we write some Java standalone programs / try to debug some web applications in Eclipse, which will generate lots of SOP / log statements. The console has a limited amount of capacity of displaying logs (even though we can change the capacity). Also if we run it again the previous console output will go away. In these cases we would require the output of the console to be written to one log file in the hard disk. You can do this in the following way :

In the eclipse Run / Debug configurations dialogue box, on the right side, you can see several tabs, where you will provide classpath, parameters, etc.
Click on the last tab, labelled as ‘Common’.
Look for the control group with title ‘Standard input and output’. There you can see one checkbox with label ‘File’.
Checking on this will activate the text box next to it. You can give the path of the log file in that text box.
You can otherwise select a directory from either workspace or file system using the corresponding buttons under that.

Don’t forget to check on the ‘Append’ checkbox if you want the log file to be keep on appending.

Now click on ‘RUN’ and you can see the new log file generated on the selected location.

Happy Coding 🙂


%d bloggers like this: