Category Archives: Java

Unable to reference local variable with JsonBuilder

I have the following code

The addTicketCommand object is not null on line 2 yet is undefined within the JsonBuilder closure. Is it not possible to access local variables in groovy from within closure?

You should be able to access addTicketCommand inside the closure as below. Mark the use of “parenthesis” instead of “curly” braces.

Download only email subject in JavaMail & imaps

I’m trying to download only subject of emails, because it should take less time (downloading ~10 emails with photos take approximately 10 min :/).

Code that I’m now using is:

it seems to me that you should look into prefetching the messages with:

LinearLayout dynamically display depending on a given number

I want to create a method that can dynamically display LinearLayout in a LinearLayout moreover that is located in a specified area in my Android application, the number of this linear layout changes depending on a given number.

Also, in each LinearLayout I want to display a Button & below it a TextView.

Here is the method I have already created:

you just need to set the layoutparams


Hibernate: How to get full sql query for method?

I’m saving new object via Hibernate. What I would like to obtain is full sql query which was use. In debug Im getting query with “?” .

How to obtain same query with values.


This is from my log4j configuration (Hibernate 3.6.8). = DEBUG, C = TRACE, C

log4j.appender.C = org.apache.log4j.ConsoleAppender

log4j.appender.C.layout = org.apache.log4j.PatternLayout

log4j.appender.C.layout.ConversionPattern = [%d{dd MMM yyyy HH:mm:ss,SSS}] %-5p %C.%M : %m%n

SQL has the logger for the SQL statement (you need to set it to DEBUG level) & BasicBinder the logger for the actual parameters (TRACE level)

JFrame doesn't add TabbedPane

My JFrame is not adding the JTabbedPane & I don’t know if the crash is some sort of bug of my eclipse. There are no syntaxes errors or anything that seems to be to me wrong. Could anyone else try to run it & see if it works? The code is already ready to run. Thanks in advance

You’ve added JMenuBar in Content pane. It is not required.

remove this line in your code mainFrame.add(bar); & mainFrame.setJMenuBar(bar); is already added.