java

Adding non printable chars to a string in Java?

I need to add some non printable chars to a string in java so it can be sent down a tcp pipe. the chars mean something to the protocol I am using (record separator and end of message respectively) what is the best way to go about doing this? Ideally I'l like to refer to them as constants so that I can use string concatonation/stringbui...

Using Python from within Java

Possible Duplicate: Java Python Integration I have a large existing codebase written in 100% Java, but I would like to use Python for some new sections of it. I need to do some text and language processing, and I'd much rather use Python and a library like NLTK to do this. I'm aware of the Jython project, but it looks like thi...

implement webcache as web application

looking for someone to verify whether this approach is good or not . let say i have web app A run on tomcat. By deploying one webcache web app on the same tomcat. will that minimum the likelyhood that my web app crash due to overload by web visitors? if yes, what webcache should i used to implement this technique? or should i forget ab...

JSF navigation redirect to previous page

Once the user successful login to the system, the system will redirect the user to the homepage. Now my problem is, if the user clicks on the view account page without login to the system the system will redirect user to the login page. if user login to the system now the system will redirect the user to the homepage, in this case any me...

What is the Java equivalent of Debugger.Launch()?

What is the Java equivalent of Debugger.Launch()? ...

Possible memory leak due to not using StringBuffer?

Can the following code cause a memory leak? Would using a StringBuffer actually improve memory usage? A little background: A coworker has been pushing his theories on memory leaks, and this is code he has identified as being problem code (without doing any sort of profiling), which he claims can cause a memory leak. I disagree with this...

Good opensource Java Shopping cart frameworks that can be extended to use Lucene and PDFbox

Hi I'm looking for a Java open source shopping cart framework. I have had a look at KonaKart and OfBiz but I'm looking for other examples for comparison. I will need to have the search on the cart use Lucene to search through the PDFs so that keywords from the documents can return results. So I will need to be able to 'hook" into the ...

How can I find out when this Java API change happened?

At some point java.lang.Override started to be available for use with implementations of methods declared in interfaces. I'm pretty sure there was a time when it just worked for overrides of methods defined in superclasses. How can I find out when (i.e. at which version) this change happened? ...

What is stored in the JNDI cache?

We are using WebSphere 6.1 on Windows connecting to a DB2 database on a different Windows machine. We are using prepared statements in our application. While tuning a database index (adding a column to the end of an index) we do not see the performance boost we saw on a test database with the same query, after changing the index the pr...

How to make repeatable unit tests of code that works with Thread.interrupt?

Consider some code that calls, say, file = new RandomAccessFile(x, "r"); file.getChannel().map(....) and wants to handle a ClosedByInterruptException circumstance. I'm stumped by how to make a realistic, repeatable unit test. To make a test, I need to somehow synchronize this thread with some other thread, and cause the other thre...

Get device unique ID

Is there a way to get a device's unique identification using MIDP2.0? ...

Should Closeable be used as the Java equivalent for .NET's IDisposable?

The Closeable interface introduced in Java 1.5 is tightly tied to streams, and even has an exception specifier for IOException. This suggests that it should only be used for streams or other IO related activities, rather than general purpose cleanup logic. Certainly the description for the close() method would make absolutely no sense o...

Page Expiration in wicket

I have a wicket Project and My page is Expiring so fast. why? ...

Java for loop vs. while loop. Performance difference?

Assume i have the following code, there are three for loop to do something. Would it run fast if i change the most outer for loop to while loop? thanks~~ int length = 200; int test = 0; int[] input = new int[10]; for(int i = 1; i <= length; i++) { for (int j = 0; j <=length - i; j++) { for (int k = 0; k < length - 1...

questions on annotation + class member order

I would like to do something like this: public class Foobar { @Tag final private int foo; @Tag final private int bar; @Tag final private int baz; @Tag final private int quux; static private final TagValidator validator = TagValidator.autoGenerate(Foobar.class); public Foobar(Something something) { va...

Exposing inner classes when obfuscating with ProGuard

I'm obfuscating a library with ProGuard using the Ant task. I'm keeping particular class names and their method names when they have a particular annotation (@ApiAll) and I'm requesting that the InnerClasses attribute be kept: <keepattribute name="InnerClasses" /> <keep annotation="com.example.ApiAll"/> <keepclassmembers annotati...

How to use hotspot probes in dtrace on Mac OS X Leopard?

My Leopard system has dtrace built in. I also have Java 6 installed, using the Apple-provided installer: $ java -version java version "1.6.0_13" Java(TM) SE Runtime Environment (build 1.6.0_13-b03-211) Java HotSpot(TM) 64-Bit Server VM (build 11.3-b02-83, mixed mode) Nevertheless, dtrace shows no hotspot probes when listing probes: $ ...

Why do my tests fail to run when migrating from maven2 to buildr?

I have a straightforward maven2 java project (JMS relaying system). After we released the first version, we found that we spent more time configuring maven than actually coding. For the next release we wanted to clean up the build process and someone suggested migrating to builder. So I was tasked with doing just that. I setup buildr...

What would cause this IllegalArgumentException during event dispatching?

This is the stack trace that is generated: Exception occurred during event dispatching: java.lang.IllegalArgumentException: Cannot format given Object as a Number at java.text.DecimalFormat.format(Unknown Source) at java.text.Format.format(Unknown Source) at javax.swing.JTable$DoubleRenderer.setValue(Unknown Source) at j...

Java gui look and feel changes

I'm new to programming, but I'm preparing to write a Java program. As I'm planning it, I'm trying to find the right gui for it. I found this page with gui options. I have two questions. 1) Will these plug just into the Java gui builder? 2) How easy (or hard) is it to change gui look and feel after the program is built? ...