java

How can I expose a C ODBC connection to a JVM using JNI?

I'm embedding a JRE in an existing C application using the invocation API, and I'd like to be able to use JDBC to work with the database in that code. This application is a transaction processing application, and the database transaction is managed by code in the C portion of the application, and the java code must run within that trans...

What are your Java 'rules'?

I'm learning Java and I'm wondering what everyone's Java rules are. The rules that you know intrinsically and if you see someone breaking them you try to correct them. Things to keep you out of trouble or help improve things. Things you should never do. Things you should always do. The rules that a beginner would not know. ...

Delphi versus C++ Builder - Which is Better Choice for a Java Programmer Doing Win32

I'm a pretty experienced Java programmer that's been doing quite a bit of Win32 stuff in the last couple of years. Mainly I've been using VB6, but I really need to move to something better. I've spent a month or so playing with Delphi 2009. I like the VCL GUI stuff, Delphi seems more suited to Windows API calls than VB6, I really like...

Can I make JUnit more verbose?

I'd like to have it yell hooray whenever an assert statement succeeds, or at the very least have it display the number of successful assert statements that were encountered. I'm using JUnit4. Any suggestions? ...

Best way to access Java classes from C++? (better than using JNI directly)

I have to integrate a large Java library in a quite large C++ application. A solution is to use JNI but this requires to hand code all the classes. Python has, for example, a wonderful solution with JPype (http://jpype.sourceforge.net/) that automatizes the process (although the same solution cannot be applied to C++ due to C++ and Pytho...

Can anyone recommend an efficient UDP messaging framework for Java?

I need to be able to send compact messages (ideally small enough to fit into a single UDP packet) from Java. It needs to be as efficient as possible - can anyone give me any pointers (other than constructing them manually)? ...

How do you determine if a JDBC Connection was retrieved from a JTA enabled DataSource or straight JDBC?

I'm using a vendor API to obtain a JDBC connection to the application's database. The API works when running in the application server or when running in a stand-alone mode. I want to run a series of SQL statements in a single transaction. I'm fine with them occurring in the context of the JTA transaction if it exists. However, if it doe...

What's the best/easiest way to manipulate ActiveX objects in Java?

I want to open and manipulate Excel files with ActiveX. I've had success with Python's Win32 Extensions and Groovy's Scriptom libraries on other projects but need to do this is pure Java this time if possible. I've tried the Jacob Java COM Bridge but that doesn't seem as straightforward or simple to use, and I couldn't get it to retr...

Configuring tomcat security manager in Eclipse

Working in Eclipse on a Dynamic Web Project (using Tomcat (v5.5) as the app server), is there some way I can configure things so Tomcat will start with security turned on (i.e. as if I ran catalina.sh start -security)? ...

J2EE Programming Skills

I have many years of experience in Java including Swing, Servlet and JDBC, but have never programmed for a J2EE server. Many job advertisements from large companies are specifically asking for J2EE experience. Are there specific skills or development environments that I should learn to qualify for these kinds of jobs? ...

Using Collections API to Shuffle

I am getting very frustrated because I cannot seem to figure out why Collections shuffling is not working properly. Lets say that I am trying to shuffle the 'randomizer' array. int[] randomizer = new int[] {200,300,212,111,6,2332}; Collections.shuffle(Arrays.asList(randomizer)); For some reason the elements stay sorted exa...

JUnit TestCase object instantiation

Is a new (or different) instance of TestCase object is used to run each test method in a JUnit test case? Or one instance is reused for all the tests? public class MyTest extends TestCase { public void testSomething() { ... } public void testSomethingElse() { ... } } While running this test, how many instances of MyTest class is ...

Distributed event handling mechanism for Java

I'm looking for a reasonably fast event handling mechanism in Java to generate and handle events across different JVMs running on different hosts. For event handling across multiple threads in a single JVM, I found some good candidates like Jetlang. But in my search for a distributed equivalent , I couldn't find anything that was lightw...

Configuring Tomcat 6 to support Russian cp1251 encoding

I am migrating a struts application from Websphere to Tomcat 6 and my application has support for Russian language. In Websphere we use to pass the JVM param -Dclinet.encoding.override=cp1251 but when I tried this with tomcat by passing the JVM argument -DFile.encoding=cp1251, the system doesnt accept input (I an any text box like in sea...

Best Way to Write Bytes in the Middle of a File in Java

What is the best way to write bytes in the middle of a file using Java? ...

GUI tool to browse Java serialized objects

Is there a GUI application that can open serialized Java object files (both binary and XML format) and display them in browsable fashion (maybe like the Eclipse debugger displays the state of variables)? It needs to work at least partially when not all classes can be resolved (an option to attach extra jars would be nice) or when there ...

How to check in Java using JIntegra if COM object implements an interface ?

I'm working with JIntegra java com bridge. I have an object of type Object which true coclass is unknown. I need to check if that object can be casted to specific COM interface (which has a proxy class generated by JIntegra). ...

Which Java Profiling tool do you use and which tool you think is the best?

Want to know what the stackoverflow community feels about the various free and non-free Java Profilers and profiling tools available. ...

Java threads: Is it possible view/pause/kill a particular thread from a different java program running on the same JVM?

I have a program 'foo' running different threads, fooT1, fooT2, .. fooTn. Now if I want write another program 'bar', which could kill the thread fooTr, is that possible? Reason: One of the thread fooTr tracks product license. If this thread is killed; one may run this product indefinitely. And killing 'foo' itself is tolerable as 'foo'...

Thread synchronization question (in java)

Hello, my java application has a loading task which requires two server calls which can be parallelized. So I launch a Thread t1 (doing task1) and a Thread t2 (for task2). I want then to do a specific task, task3 when both other tasks (1 & 2) are over. Naturally I can't tell which of task1 and task2 will finish first... Which would be f...