java

What is the best way to deal with environment specific configuration in java?

I have an application running in tomcat that has a bunch of configuration files that are different for each environment it runs in (dev, testing, and production). But not every line in a config file will be different between environments so there's invariably duplicated information that doesn't get updated if something changes. Is ther...

Java- Changing swing background colour?

Ok so ive got a bitchin swing app going using the "System" look and feel. Now, I want to change the background colour of the main panels to black. Too easy right? UIManager.put("Panel.background", Color.BLACK); Well yeah, except now the controls in the app look stupid, because their 'shadows', for want of a better word, are graduated...

Benefits of 64bit Java platform

I'm an absolute n00b into the java platform I would like to know whether I need to change anything in my code to get the benefits of 64bit JRE ? or is it something like when I initiate it with "java -d64" its gonna run in some turbo mode? Your help is highly appreciated ...

Eclipse - generated method parameters final

Can Eclipse make parameters for generated methods (overwriting, implementing interface, etc.) final. If yes - how? If I'm not mistaken, then IntelliJ had an option for it. I could not something similar in Eclipse. This has become a part of my coding style and I am making parameters final manually, but there has to be a faster way :P ...

How do I read strings in J2ME?

I'm using the MIDP 2.0 (JSR 118) and I just noticed that there is no reader for strings in J2ME. Does anyone know how you are supposed to read Strings from an InputStream or InputStreamReader in a platform independent way (i.e. between two java enabled cell phones of different models)? ...

What is the technical term for C# or Java type languages?

This is probably a very simple question, but what is the technical term for this class of language? They use an "intermediate" assembly type language which is sent through the JVM or CLR. They both are object oriented and they both depend on an intermediary such as the Java Virtual Machine or the Common Language Runtime to compile in...

Deep cloning multidimensional arrays in Java... ?

I have two multidimensional arrays (well actually they're only 2D) which have inferred size. How do I deep clone them? Here's what I have gotten so far: public foo(Character[][] original){ clone = new Character[original.length][]; for(int i = 0; i < original.length; i++) clone[i] = (Character[]) original[i].clone(); } A test for...

How do I get a list of Java Class dependencies for a Main class?

Is there a way to find all the class dependencies of a java Main class? I have been manually sifting through the imports of the Main class and it's imports but then realised that, because one does not have to import classes that are in the same package, I was putting together an incomplete list. This should be recursive (perhaps to a d...

How do I tell Java to map a logical font (e.g. SansSerif) to a specific font on my system?

Is there a way to map a logical font (e.g. SansSerif) to a different font when running a Java program? If so, does the method differ between Java VM versions? ...

run oracle sql script from java

i have a bunch of sql scripts that should upgrade the database when the java web application starts up. i tried using the ibatis scriptrunner, but it fails gloriously when defining triggers, where the ";" character does not mark an end of statement. now i have written my own version of a script runner, which basically does the job, but...

Java Webservice testing

Hi I provide a web service to my organisation. i was wondering would anyone recommeding the use of apache cactus for setting up a testing framework or has anyone worked with any other web service frameworks that may be useful? Thanks Damien ...

Can you recommend a Java library for reading (and possibly writing) CSV files?

Can you recommend a Java library for reading, parsing, validating and mapping rows in a comma separated value (CSV) file to Java value objects (JavaBeans)? ...

How to use Special Chars in Java/Eclipse

How can I use/display characters like ♥, ♦, ♣, or ♠ in Java/Eclipse? Wenn I try to use them directly, i.e. in the source code, Eclipse cannot save the file: What can I do? Edit: How can I find the unicode escape sequence? ...

How do I split strings?

How do I split strings in J2ME in an effective way? There is a StringTokenizer in the standard edition, but it is absent in the micro edition. ...

What is the buffer size to create a .zip archive using Java?

Hello, I use this code to create a .zip with a list of files: ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zipFile)); for (int i=0;i<srcFiles.length;i++){ String fileName=srcFiles[i].getName(); ZipEntry zipEntry = new ZipEntry(fileName); zos.putNextEntry(zipEntry); InputStream fis = new FileInputStream...

How do I parse a base query (à la Google Data) in Java?

I have a system where I query a REST / Atom server for documents. The queries are inspired by GData and look like : http://server/base/feeds/documents?bq=[type in {'news'}] I have to parse the "bq" parameter to know which type of documents will be returned without actually doing the query. So for example, bq=[type = 'news'] ...

How do I make vim indent java annotations correctly?

When indenting java code with annotations, vim insists on indenting like this: @Test public void ... I want the annotation to be in the same column as the method definition but I can't seem to find a way to tell vim to do that, except maybe using an indent expression but I'm not sure if I can use that together with regular cindent...

Hibernate Union alternatives

What alternatives do I have to implement a union query using hibernate? I know hibernate does not support union queries at the moment, right now the only way I see to make a union is to use a view table. The other option is to use plain jdbc, but this way I would loose all my example/criteria queries goodies, as well as the hibernate ma...

Unit testing for safe publication.

How would you unittest a safe-publication guarantee in Java? To be concrete: I have a Cache interface that has a method getOrLoad(K key, ObjectLoader loader). Thing is, if a Cache cannot find an object for the given key, then it must load it from the ObjectLoader instance. However, the Cache is required to guarantee that the act of loa...

Using system environment variables in log4j xml configuration

Is it possible to reference system environment variables (as opposed to Java system properties) in a log4j xml configuration file? I'd like to be able to do something like: <level value="${env.LOG_LEVEL}" /> and have it get that from the system environment variables, so I can avoid having to pass in so many things with -D parameters....