java

After C++ - Python or Java?

I'm fast approaching the point in my coding where I would like to quickly write object oriented code in languages other than C++ for a variety of reasons. After a lot of research, my choices have pretty much narrowed down to Python and Java. I'm leaning towards Python because of its relationship to C, but with Java, from what I can see...

Too many "pattern suffixes" - design smell?

I just found myself creating a class called "InstructionBuilderFactoryMapFactory". That's 4 "pattern suffixes" on one class. It immediately reminded me of this: http://www.jroller.com/landers/entry/the_design_pattern_facade_pattern Is this a design smell? Should I impose a limit on this number? I know some programmers have similar...

Is there something like ZenTest/Autotest for Java and JUnit

I've used ZenTest and autotest to work on Ruby projects before, and I used to using them for test-driven development a la this configuration. I have a project that I'm currently working on in Java, and I was wondering if there is something similar in the Java world to achieve the same effect. ...

How to solve performance problem with Java SecureRandom?

If you want a cryptographically strong random number in Java, you use SecureRandom. Unfortunately, SecureRandom can be very slow. If it uses /dev/random on Linux, it can block waiting for sufficient entropy to build up. How do you avoid the peformance penalty? Has anyone used Uncommon Maths as a solution to this problem? Can anybody co...

Code run by Hudson can't find executable on the command line

I'm setting up my first job in Hudson, and I'm running into some problems. The job monitors two repositories, one containing our DB setup files, the other a bit of code that validates and tests the DB setup files. Part of the code that runs will throw the validated setup files at PostgreSQL, using the psql command line tool, using Runti...

How do you pipe an inputstream to a zipped file as it's read in with Java?

I'm wanting to execute a program and as it runs read in it's output and pipe out the output into a zipped file. The output of the program can be quite large so the idea is to not hold too much in memory - just to send it to the zip as I get it. ...

Which distro of Linux is best suited for Java web apps?

There are so many Linux distributions to choose from! What is the "best" linux flavor for a web hosting environment running primarily: Apache HTTP, Tomcat or JBoss, MySQL and Alfresco (not necessarily all in the same instance). Are there any significant differences in terms of ease of administration and configuration, performance and s...

Using "final" modifier whenever applicable in java

In Java, there is a practice of declaring every variable (local or class), parameter final if they really are. Though this makes the code a lot more verbose, this helps in easy reading/grasping of the code and also prevents mistakes as the intention is clearly marked. What are your thoughts on this and what do you follow? ...

Hudson job hangs at Runtime.exec

I'm running Hudson as a windows service through Tomcat, with no slaves involved. The last build step in the job is a batch file that invokes some Java code. The code uses PostgreSQL's command line tool psql (via Runtime.exec()) to create a database on the local machine and eventually run some tests against it. The job will progress to t...

Is it possible to call a COM API from Java?

Is it possible to call a COM API from Java (specifically the HP/Mercury Quality Center OTA API)? If so, what's the best way? Is something like JACOB appropriate? Code fragments would be helpful for the basics :-) ...

Detecting file being reopened in Java

I'm working on a small Java application (Java 1.6, Solaris) that will use multiple background threads to monitor a series of text files for output lines that match a particular regex pattern and then make use of those lines. I have one thread per file; they write the lines of interest into a queue and another background thread simply mon...

How do I find my PID in Java or JRuby on Linux?

I need to find the PID of the current running process on a Linux platform (it can be a system dependent solution). Java does not support getting the process ID, and JRuby currently has a bug with the Ruby method, Process.pid. Is there another way to obtain the PID? ...

How do I add a type to GWT's Serialization Policy whitelist?

GWT's serializer has limited java.io.Serializable support, but for security reasons there is a whitelist of types it supports. The documentation I've found, for example this FAQ entry, says that any types you want to serialize "must be included" on the whitelist, and that the list is generated at compile time, but doesn't explain how th...

What happens when I click the Stop button on the browser?

Let's say I click a button on a web page to initiate a submit request. Then I suddenly realize that some data I have provided is wrong and that if it gets submitted, then I will face unwanted consequences (something like a shopping request where I may be forced to pay up for this incorrect request). So I frantically click the Stop butto...

Java - Console-like web applet.

Hey, I've been developing an application in the windows console with Java, and want to put it online in all of its console-graphics-glory. Is there a simple web applet API I can use to port my app over? I'm just using basic System.out and System.in functionality, but I'm happy to rebuild my I/O wrappers. I think something along these ...

Calling .NET assembly from Java: JVM crashes

I have a third party .NET Assembly and a large Java application. I need to call mothods provided by the .NET class library from the Java application. The assembly is not COM-enabled. I have searched the net and so far i have the following: C# code (cslib.cs): using System; namespace CSLib { public class CSClass { publi...

How to determine from within Java which .NET framework is installed

From within my Java program I want to determine which .NET Framework is installed on the system. What is the best (and easiest) way to do this? Answer Thanks scubabbl! It worked to check the directory System.getenv( "WINDIR" ) + "\\Microsoft.NET\\Framework" for its directories starting with the letter "v". ...

What are Java command line options to set to allow JVM to be remotely debugged ?

I know there's some JAVA_OPTS to set to remotely debug a Java program. What are them and what does they mean ? ...

Java Swing: Ctrl+F1 does not work globally, but each other key combination

Hello, I have a swing gui with a tabbed pane in the north. Several key events are added to its input map: InputMap paneInputMap = pane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); paneInputMap.put( KeyStroke.getKeyStroke( KeyEvent.VK_E, KeyEvent.CTRL_MASK ), "finish"); paneInputMap.put( KeyStroke.getKeyStroke( KeyEvent.V...

How to create a GET request with parameters, using JSF and navigation-rules?

Is there a way to create an html link using h:outputLink, other JSF tag or code to create a non faces request (HTTP GET) with request parameters? For example I have the following navigation-rule <navigation-rule> <navigation-case> <from-outcome>showMessage</from-outcome> <to-view-id>/showMessage.jsf</to-view-id> ...