java

Are there any examples of code that is difficult to decompile?

Sometimes when decompiling Java code, the decompiler doesn't manage to decompile it properly and you end up with little bits of bytecode in the output. What are the weaknesses of decompilers? Are there any examples of Java source code that compiles into difficult-to-decompile bytecode? Update: Note that I'm aware that exploiting this ...

What's Java's equivalent of .Net's Interlocked class?

How do I modify an int atomically and thread-safely in Java? Atomically increment, test & set, etc...? ...

How can I give my Java application a unique process name?

I've noticed that when I start Netbeans it shows up in the task manager as netbeans.exe as all my own Java applications show up as java.exe or javaw.exe. How can I change that so my process names shows up as myapp.exe? ...

Programmatically call default media player in Blackberry?

Like I said, the application has to call the default Blackberry media player.Does anybody know or maybe point in a direction to implement it Enviroment : Eclipse+BB plugin 4.5 ...

Get JVM to grow memory demand as needed up to size of VM limit?

We ship a Java application whose memory demand can vary quite a lot depending on the size of the data it is processing. If you don't set the max VM (virtual memory) size, quite often the JVM quits with an GC failure on big data. What we'd like to see, is the JVM requesting more memory, as GC fails to provide enough, until the total a...

Searching text with 'Match case' and 'Match whole word' in file in C++ or Java

Hi. I need a solution in C++ or Java. Are there standard functions? ...

JBuilder 2006 multiple encodings

Hi, I just got a project in Borland JBuilder 2006 that I cannot even build. I have two resource files, one with Simplified Chinese text and the other in Traditional Chinese. When I try to build the project the text is misinterpreted and it sees an "illegal escape character". Now if I set the encoding in Project -> Project Properties ->...

Maven jetty plugin - delay when starting in background mode

I start a jetty server on linux using nohup mvn jetty:run & to run it in background and to stay when I quit from the console. Usually (mvn jetty:run) it starts in seconds, but in this case it takes about minute to start. What can be the cause of such a delay? Thanks. ...

Looking for a capturing impl of HttpServletResponseWrapper

The JavaEE API comes with the HttpServletResponseWrapper which, to quote the javadoc, "provides a convenient implementation of the HttpServletResponse interface that can be subclassed by developers wishing to adapt the response from a Servlet." Without subclassing, this class just passes all calls through to the wrapped response object. ...

Java Calendar.set not giving correct result

I can't see where I'm going wrong with the code below, its probably something obvious but I'm too blind to see it at this stage. I'm passing a date of "01/01/2009" to an instance of calendar. I then try and set the month to 2 for March and the output I see is formatted: 01/01/2009 cal month: 2 cal.set( Calendar.MONTH, mth ); //mth = ...

Formatting a double output using BufferedWriter in Java

I'm working on an assignment, and have completed the code, however I am having an issue with correct formatting of the output. I am taking a text file, separating the products based by price, and appending the data to two separate files. How do I make the format of the double correct with the BufferedWriter so that it appears as money ...

Why InputStream and OutputStream implement Closeable and Socket doesn't?

Have seen this comment in a method: //I wonder why Sun made input and output streams implement Closeable and left Socket behind It would prevent creation of wrapper anonymous inner class which implements Closeable which delegates its close method to an instance of Socket. ...

Does Android castrate the ARM's Jazelle technology?

The justification that I've seen for shall we say "Bastardizing" the Java bytecodes in Android was performance. (I suspect there is another reason.) However by changing the byte codes haven't they made hardware excelleration technologies such as Jazelle moot, and thus actually degraded the performance available for a Mobile Java platfo...

GWT panel design best practices

I am a newbie in GWT, and also to Swing/SWT style interface building. I have worked with HTML for a long time, and I know how to build my UIs in that. However, I am having trouble translating this to GWT. What I am trying to make currently, is a simple UI with a table on the left with 4 columns, heading and a caption, and a panel on the ...

How to include files in java ? Is it possible in Eclipse IDE?

Hi, Is it possible to include files in java source files somehow? Thanks. ...

Best practice for including version info in Java web apps and libraries?

I'm working on a project that is implementing a number Java web applications (and associated JAR files) using Seam. What is considered best practice with regard to including version information in deployments? What I need to understand is how web applications should contain and publish their versions and how the same can be done for JA...

Tests frameworks and tools for SOA Java developments

Currently, I'm looking for any experiences or advices about test tools on Service Oriented Architecture (SOA) Java developments. Which the bestpratices and best tools for this job ? Thanks for your time ...

In Java, how do I ensure a dummy class is never used?

I am working on a project in which, to resolve a versioning issue, I am creating many classes which will never be tested and must not ever be used - they just need to be there to keep the compiler happy. I'd like to make sure they are never used. This morning I had the idea of throwing an exception in a static initialization block: pu...

Java Classpath problem

I have a Java Program that references a Jar File. The Jar File is present in the same directory as the .class File but when I try to run the program from console, I get NoClassDefFound error :-( Alternatively it runs Ok from Eclipse. Why ? ...

Is it possible to use DWR if the DWR servlet is deployed in a different war?

I wanted to use DWR from web application A, but the DWR servlet is in web application B. Is this possible? Is there any work-around? Thanks! ...