java

Trouble playing wav in Java

I'm trying to play a PCM_UNSIGNED 11025.0 Hz, 8 bit, mono, 1 bytes/frame file as described here (1) and here(2). The first approach works, but I don't want to depend on sun.* stuff. The second results in just some leading frames being played, that sounds more like a click. Can't be an IO issue as I'm playing from a ByteArrayInputStre...

Experiencing occasional long garbage collection delays, why?

I'm having a hard time dealing with a Java garbage collection problem, and interpreting the logs. My application requires that no GC takes longer than 2 seconds, and ideally less than 100ms. Based on some previous advice I'm trying the following command line options: java -XX:MaxGCPauseMillis=100 -XX:NewRatio=9 -XX:+UseConcMarkSweepG...

Convert from Codepage 1252 (Windows) to Java, in Java

Hi! I have some strings in Java (originally from an Excel sheet) that I presume are in Windows 1252 codepage. I want them converted to Javas own unicode format. The Excel file was parsed using the JXL package, in case that matter. I will clarify: apparently the strings gotten from the Excel file look pretty much like it already is some...

How can I run updates in SVN without causing many conflicts.

I am using SVN to develop some software in a team of four people. Whenever I update my working copy, it creates far more conflicts than I would expect to be created, a large number of these conflicts are like so: If the initial was import Class1 and I change it to import Class1 import Class2 while another team member changes the...

Accurracy of technical arguments in JWZ's ten-year-old "java sucks" article with today's Java?

I'm currently using Java in a larger project and was curious which of the technical arguments in JWZ's famous "java sucks" article were still valid ten years later. The article starts like this: I think Java is the best language going today, which is to say, it's the marginally acceptable one among the set of complete bagbiting loser...

JTextPane keeps throwing BadLocation

I have a JFrame that contains a JTextPane. The purpose of this JTextPane is to highlight words as I type them, something along the lines of a programmer's text editor. To accomplish this, I extended JTextPane, I implemented the KeyListener interface, and I had it setup as a key listener to self. The method that does some important work i...

Unable to call a web service from Groovy

I'm going through the first examples from the new Java Web Services: Up and Running book. I tried to go through the SOAP client example for Java on page 13, but in Groovy. So here is my Groovy shell code: import javax.xml.namespace.QName import javax.xml.ws.Service import java.net.URL url = new URL("http://someURL?wsdl") qname = new Q...

What is the recommended/standard install path for apache-tomcat on a linux box

Hello I am looking to install Apache-Tomcat on a RedHat linux and I am interested if there is a standard place for this to be installed. in other work I have seen tomcat installed at /opt/apache-tomcat-[VERSION]/ but I would expect it to be found under /usr. Best answer will have a link to authoritative site. Thanks so much, David. ...

Generating client code with wsdl2js?

I am trying to use wsdl2js to generate the client-side handler of a SOAP request for a WSDL file but running into a few problems. If I use: >wsdl2js -p [projectName] [wsdlFile] it only generates a javascript file, which isn't what I need. If I use wsdl2js -client [wsdlFile] like they demonstrate, I get an "Unexpected option: -...

what is the equivalent of the following jdk path in slicehost ubuntu?

I got to setup the following two variables: export LD_LIBRARY_PATH=/usr/java/jdk1.6.0/jre/lib/i386/:/usr/java/jdk1.6.0/jre/lib/i386/client/:./ export JAVA_HOME=/usr/java/jdk1.6.0/ Since, the above is for the version of jdk installed via SunJDK, what could be the equivalent path for the openjdk-6-jdk package! My OpenJDK is installed at...

Common algorithm for generating a diff of the fields in two beans?

Let's say you have two instances of the same bean type, and you'd like to display a summary of what has changed between the two instances - for example, you have a bean representing a user's settings in your application, and you'd like to be able to display a list of what has changed in the new settings the user is submitting (instance #...

Capture stdout in log4j/log4net

I have a library that writes to stdout in Java. I would like to capture this output in a log using log4j. (I didn't write this library, so I have no control over the code inside the library). Is there an easy way to do this? Is System.setOut the right approach? What do I pass to System.setOut? Also, how would you do this in .NET/C#...

Create a Java File object (or equivalent) using a byte array in memory (without a physical file)

I want to create a Java File object in memory (without creating a physical file) and populate its content with a byte array. Can this be done? The idea is to pass it to a Spring InputStreamSource. I'm trying the method below, but it returns saying "the byte array does not contain a file name.". MimeMessage message = mailSender.create...

javadoc: @version and @since

Is there a reason to include both @version and @since as part of a class? They seem to be mutually exclusive. Also, what does %I% and %G% mean, and how to set/use them? @version %I%, %G% thanks ...

Sending Dates over RMI between machines in different regions

I'm having a problem sending java.util.Date objects over RMI, to and from machines in different timezones. For example, a client in Germany will send a date object to a server in the UK. User enters a date string e.g. 20090220. Client app in Germany converts it to date using SimpleDateFormat("yyyyMMdd") to give: Fri Feb 20 00:00:00 C...

Accessing the content of a JAX-WS Dispatch Response

I'm trying to access a web service with JAX-WS using: Dispatch<Source> sourceDispatch = null; sourceDispatch = service.createDispatch(portQName, Source.class, Service.Mode.PAYLOAD); Source result = sourceDispatch.invoke(new StreamSource(new StringReader(req))); System.out.println(sourceToXMLString(result)); where: private static Stri...

how to give wait & close the command prompt in java

I am using the following code to execute a batch file: java.lang.Runtime rt = java.lang.Runtime.getRuntime(); Process pr = rt.exec("MyBatch.bat"); My batch file takes some time to execute. I want my servlet process to wait till the batch file execution completes. I would like to close the command prompt after executing the batch file....

Constructing a DataFlavor for drag and drop of an array of java objects

I want to implement drag and drop between two components within the same JVM. I'm passing an array of objects which are not serializable, so I'm trying to find the correct incantation of javaJVMLocalObjectMimeType to pass in. However, I keep getting an illegal argument exception. As an example, if i have ExampleClass Appending class p...

Do 2D arrays use more resources than 1D arrays in Java?

For example, would a full int[50][8] use more resources (RAM and CPU) than 8 full int[50] arrays? ...

How can I hide all java.lang.Object methods from code completion?

Hello, i want to create some simple wrapper classes for an existing class library. To make the syntax nice to read AND nice to guess (via code completion) i'd like to remove the methods of java.lang.Object. The problem is that all non-atomic things in java inherit from Object and thus have these methods. I already tried to create the wr...