java

Calling C# code from Java?

Does anyone have a good solution for integrating some C# code into a java application? The code is small, so I could re-write in java, but I would rather reuse the code if possible. Don't repeat yourself, etc. Also, I know I can expose the C# as a web service or whatever, but it has some security/encryption stuff in there, so I would...

What is a regex "independent capturing group"?

From the Java 6 Pattern documentation: Special constructs (non-capturing) (?:X)   X, as a non-capturing group … (?>X)   X, as an independent, non-capturing group Between (?:X) and (?>X) what is the difference? What does the independent mean in this context? ...

How do I format a number in java?

How do I format a number in java? What are the "Best Practices"? Will I need to round a number before I format it? "32.302342342342343" formatted to "32.30" ".7323" formatted to "0.73" etc. ...

Programmatically determine which Java thread holds a lock

Is it possible at runtime to programmatically check the name of the Thread that is holding the lock of a given object? ...

Java Desktop application framework

Hi, I am working on designing and building a desktop application. I am thinking about using eclipse or netbeans for the base of this application. However, I have never built on either of these platforms. I am personally leaning to using netbeans because it seams like that platform is an easer learning curve. But, I wanted to ask peo...

Can the Weblogic default handler display the list of contexts?

In Jetty, if there is no deployment at '/' then the DefaultHandler displays a list of known contexts. This is very useful during development. Is it possible to configure BEA Weblogic to provide a similar convenience? ...

High availability and scalable platform for Java/C++ on Solaris

I have an application that's a mix of Java and C++ on Solaris. The Java aspects of the code run the web UI and establish state on the devices that we're talking to, and the C++ code does the real-time crunching of data coming back from the devices. Shared memory is used to pass device state and context information from the Java code thro...

Performance gain in compiling java to native code?

Is there any performance to be gained these days from compiling java to native code, or do modern hotspot compilers end up doing this over time anyway? ...

Find all drive letters in Java

For a project I'm working on. I need to look for an executable on the filesystem. For UNIX derivatives, I assume the user has the file in the mighty $PATH variable, but there is no such thing on Windows. I can safely assume the file is at most 2 levels deep into the filesystem, but I don't know on what drive it will be. I have to try al...

When can DataInputStream.skipBytes(n) not skip n bytes?

The Sun Documentation for DataInput.skipBytes states that it "makes an attempt to skip over n bytes of data from the input stream, discarding the skipped bytes. However, it may skip over some smaller number of bytes, possibly zero. This may result from any of a number of conditions; reaching end of file before n bytes have been skipped i...

Where did all the java applets go?

When java was young, people were excited about writing applets. They were cool and popular, for a little while. Now, I never see them anymore. Instead we have flash, javascript, and a plethora of other web app-building technologies. Why don't sites use java applets anymore? I'm also curious: historically, why do you think this occur...

Getting A File's Mime Type In Java

I was just wondering how most people fetch a mime type from a file in Java? So far I've tried two utils: JMimeMagic & Mime-Util. The first gave me memory exceptions, the second doesn't close its streams off properly. I was just wondering if anyone else had a method/library that they used and worked correctly? ...

Best practice for Java IPC

Dear all, what is the best method for inter process communication in a multithreaded java app. It should be performant (so no JMS please) easy to implement and reliable,so that objects & data can be bound to one thread only? Any ideas welcome! Thanks Okami ...

Good Java graph algorithm library?

Has anyone had good experiences with any Java libraries for Graph algorithms. I've tried JGraph and found it ok, and there are a lot of different ones in google. Are there any that people are actually using successfully in production code or would recommend? To clarify, I'm not looking for a library that produces graphs/charts, I'm look...

Java Generics: Comparing the class of Object o to <E>

Let's say I have the following class: public class Test<E> { public boolean sameClassAs(Object o) { // TODO halp! } } How would I check that o is the same class as E? Test<String> test = new Test<String>(); test.sameClassAs("a string"); // returns true; test.sameClassAs(4); // returns false; I can't change the method s...

Extracting SVN data with Java

Does anyone know a good Java lib that will hook into SVN so I can extract the data? I want the SVN comments, author, path, etc... Hopefully with this data I can build a better time management tracking system. ...

What is causing a JVMTI_ERROR_NULL_POINTER?

I'm getting an error when my application starts. It appears to be after it's initialized its connection to the database. It also may be when it starts to spawn threads, but I haven't been able to cause it to happen on purpose. The entire error message is: FATAL ERROR in native method: JDWP NewGlobalRef, jvmtiError=JVMTI_ERROR_NULL_POI...

In Java, what is the best way to determine the size of an object?

For example, let's say I have an application that can read in a CSV file with piles of data rows. I give the user a summary of the number of rows based on types of data, but I want to make sure that I don't read in too many rows of data and cause OutOfMemory Exceptions. Each row translates into an object. Is there an easy way to find ...

Building Apps for Motorola Cell Phone

I have an L6 phone from motorola, a usb cable to connect it to my computer, and the Tools for Phones software so I can do things like upload my own custom ringtones or download pictures from the phone's camera. I have some ideas for programs I'd like to run on the phone, and it supports java, but I don't see anything in the software tha...

How do you keep the machine awake?

I have a piece of server-ish software written in Java to run on Windows and OS X. (It is not running on a server, but just a normal user's PC - something like a torrent client.) I would like the software to signal to the OS to keep the machine awake (prevent it from going into sleep mode) while it is active. Of course I don't expect the...