java

Remove project .jars from project explorer view in Eclipse

the list of jars just takes too much place. Can I collapse it or hide it? ...

Is there a way for anonymous inner classes in Java to "lose" their scope?

When I pass an anonymous inner class into a function, I can refer to variables in the current scope from within a method of that class, like so: class Caller { private Object callerPrivate; // ... public void someMethod() { final String callerLocal = "Eyes only"; ISomeInterface anon = new ISomeInterface() ...

Disable serialization cache

Is there a way to disable caching of serialized object in Java? I have this scenario: I have an object which is Serializable, I am serializing it, deserializing it, values are OK. On the same object, I am changing some value, I am serializing it, deserializing it, values are NOT OK, values are same as the first initially loaded. See...

swt.graphics.ImageLoader.save() not flushed?

I'm using this class swt.graphics.ImageLoader to save a file as a PNG: ImageLoader loader = new ImageLoader(); loader.data = new ImageData[] { m_imgdat }; loader.save(selected, SWT.IMAGE_PNG); Yet sometimes the file I get is incomplete. the last line of pixels is black and some programs (photoshop) refuse to open it altogether. Is the...

Exposing multiple objects with RMI in Spring

How do I expose multiple objects with RMI using Spring? I start with what is written here. What if I want to expose more objects, must I declare another instance of RMIServiceExporter? ...

plugin.properties mechanism in eclipse RCP

My project includes multiple plugins and every plugin includes the plugin.properties file with near to 20 translations. The MANIFEST.MF file defines the name of the properties files where the external plugin strings are stored. Bundle-Localization: plugin The name of the plugin i define like %plugin.name Eclipse will search the "%p...

What's the point of JAAS

What's the point of JAAS if I have to write my own {whatever}LoginModule and everything else? ...

Can Java Code tell if it is in an App Server?

Is there something I can call from a POJO to see if the code is currently in an App Server or outside of an App Server? Something like this (In rough PseudoCode): System.getRunningEnvironment().equals(Environment.Glassfish) or System.getRunningEnvironment().equals(Environment.ApplicationServer) or System.getRunningEnvironment().e...

Run CMD equivalent in OSX?

I'm using this code to make my Java program open a (visible) CMD window: try { String line; Process p = Runtime.getRuntime().exec("cmd /C start \"Render\" \"" + myPath + "\\punchRender.cmd\""); BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream())); ...

Using hibernate criteria, is there a way to escape special characters?

For this question, we want to avoid having to write a special query since the query would have to be different across multiple databases. Using only hibernate criteria, we want to be able to escape special characters. This situation is the reason for needing the ability to escape special characters: Assume that we have table 'foo' in ...

EJB3 - handling RollBackExceptions

Hi all, I have an EJB3 application which consists of some EJB's for accessing a DB, and exposed via a Session Bean as a web service. Now there are two things I need to find out: 1) Is there any way I can stop SQL exceptions from causing the web service from throwing a SOAP Fault? The transactions are handled by the container, and curr...

How can I prevent PermGen space errors in Netbeans?

Every 15-30 minutes Netbeans shows a "java.lang.OutOfMemoryError: PermGen space". From what I learned from Google this seems to be related to classloader leaks or memory leaks in general. Unfortunatly all suggestions I found were related to application servers and I have no idea to adapted them to Netbeans. (I'm not even sure it's the s...

Write an executable .sh file with Java for OSX

So I am trying to write an .sh file that will be executable, this is how I'm currently writing it: Writer output = null; try { output = new BufferedWriter(new FileWriter(file2)); output.write(shellScriptContent); output.close(); } catch (IOException ex) { Logger.getLogger(PunchGUI.class.getName()).log(Level.SEVERE, null, ex); }...

Why is Java giving me an IllegalArgumentException?

I'm using dwr and spring and I get this error: java.lang.IllegalArgumentException: Javascript name * is used by 2 classes I found nothing helpful on Google, do you know why I'm getting this error? <?xml version="1.0" encoding="UTF-8"?> <beans xmlns:dwr="http://www.directwebremoting.org/schema/spring-dwr" http://www.directwebre...

How can I make java.text.NumberFormat format 0.0d as “0” and not “+0”?

Need result with sign, except for 0.0d. Ie: -123.45d -> "-123.45", 123.45d -> "+123.45", 0.0d -> "0". I invoke format.setPositivePrefix("+") on the instance of DecimalFormat to force the sign in the result for positive inputs. ...

How can I profile a very large Java webapp?

I have a very large Java app. It runs on Tomcat and is your typical Spring/Hibernate webapp. It is also an extremely large Java program. It's easy for me to test the performance of database queries, since I can run those separately, but I have no idea to look for Java bottlenecks on a stack like this. I tried Eclipse's TPTP profiler,...

How can I find out the length of a column in a JPA @Entity?

I've got a String column defined with @Column(length = 4000) The attribute contains log information and can be longer than the defined length. In this case, the field can be safely truncated without throwing an error message. I'd like to find out the determined length of the column in the DAO class for the pojo so that I can truncat...

Does anyone know how to extract a date from a record in java?

I have a date propety set up like this cal1.setTime(StartDate.getDate()); strStartDate = cal1.get(cal1.DAY_OF_MONTH) + "/" + (cal1.get(cal1.MONTH) + 1) + "/" + cal1.get(cal1.YEAR); And I need to extract it when a search is performed. I so far have this int endOfName = rec...

Is there an elegant way to convert ISO 639-2 (3 letter) language codes to Java Locales?

E.g. eng, spa, ita, ger I could iterate all locales and compare the codes, but I wonder whether there is a more elegant & performant way to achieve this.... Thanks a lot for any hints :) ...

Jpa composite key nullable columns

Hi, I'm using Hibernate's JPA impl to model some tables. I'm having trouble mapping a table that: Has no primary key Has a unique index on 4 columns, 3 of which can be nullable I tried to hack it and define the index as a composite Id, but since some columns are nullable this is not working properly. Is this possible with JPA/Hibern...