java

How do you manage Hibernate's zillion JAR files

For my previous employer I've worked with Hibernate, and now that I'm in a small startup I would like to use it again. However, downloading both the Hibernate core and the Hibernate annotations distributions is rather painful, as it requires putting a lot of JAR files together. Because the JARs are split up into categories such as "requi...

Iterator for all elements in hash maps stored in an array

I have a custom made class called Graph in which I use adjacency lists. To be more specific, I have an array of hash maps where each hash map contains all that node's neighbors as edges. The key is the end node and the value is an Edge object. Now i want to make this Graph class implement Iterable. Is there a way of merging all those h...

JavaME-suitable grammar compiler recommendations?

I want to parse some data, and I have a BNF grammar to parse it with. Can anyone recommend any grammar compilers capable of generating code that can be used on a mobile device? Since this is for JavaME, the generated code must be: Hopefully pretty small Low dependencies on exotic Java libraries Not dependant on any runtime jar files. ...

String indexed collection in Java

Using Java, assuming v1.6. I have a collection where the unique index is a string and the non-unique value is an int. I need to perform thousands of lookups against this collection as fast as possible. I currently am using a HashMap<String, Integer> but I am worried that the boxing/unboxing of the Integer to int is making this slower. ...

Need an example - decrypting string in Java using Microsoft Crypto API

First and foremost, I am not a Java programmer. I'm looking for an example solution to this problem because the Java developer I have does not have much experience working with encryption. Everything we've found online pertains to encrypting web pages and dealing with the MS keystore. We just want to work with a single string from Pow...

How do I record sound and send it to a server from a web application?

I'm developing a web application. It will allow people to link written phrases with spoken phrases. In order for this application to be useful, random users must be able to record their own voices and send the sounds to the server. If I just have an "upload wav" form, no one will use it. If I have a "record" button that streams or pa...

Is there a library to convert Java POJOs to and from JSON and XML?

I have an object graph that I would like to convert to and from JSON and XML, for the purposes of creating a REST-style API. It strikes me that someone must have done this already, but a quick search using Google and Stack Overflow reveals nothing. Does anyone know of a suitable (Apache or equivalent license preferred) library to do th...

Java - If statement with String comparison fails

I really don't know why the if statement below is not executing: if (s == "/quit") { System.out.println("quitted"); } Below is the whole class. It is probably a really stupid logic problem but I have been pulling my hair out over here not being able to figure this out. Thanks for looking :) class TextParser extends Thread { ...

Web based email reply/quoting code available?

I'd like to write a sort of mini-CRM system that will require interacting with emails from customers (many different systems). I'd like for it to be able to reply to their emails, and place the original email in a nice quoted reply format like other email apps. This appears to be fairly easy when responding to an ASCII email, but how d...

Ensuring that a JButton can fit a String of a given length

Let's say I have a JButton, and I want it to be big enough to fit a string of 8 "M" characters, regardless of the string that is actually assigned to it and the font size, without using elipsis. The JButton has to have precisely this size, no more, no less. Layout manager in use is GridBagLayout. I tried overwriting the getPreferredSi...

Large file uploads with Java applet

Hi, I've been tasked with implementing large (2gb+) file uploads via a web browser. After evaluating various technologies, java applets seem to be the way forward (only one's which provide proper access to the local disk). I was wondering if anyone can recommend a 3rd party file upload app we can use as a base? requirements are Decen...

How to configure Hibernate Tools HQL editor in Eclipse with a custom NamingStrategy

I've installed Hibernate Tools 3.2.4.GA in Eclipse Ganymede. The main driver for installing it was to be able to issue HQL queries interactively. I have configured all of our mapping files, hibernate.properties, etc. and it shows all of our entities and mappings and is able to read a list of tables from the database. It doesn't appe...

How would you change a single byte in a file?

What is the best way to change a single byte in a file using Java? I've implemented this in several ways. One uses all byte array manipulation, but this is highly sensitive to the amount of memory available and doesn't scale past 50 MB or so (i.e. I can't allocate 100MB worth of byte[] without getting OutOfMemory errors). I also implemen...

How can I find all classes on the classpath that have a specific method annotation?

I want to implement an intialization mechanism that is annotation-based in Java. Specifically, I have an annotation I've defined: @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) public @interface Initialization { /** * If the eager initialization flag is set to <code>true</code> then the * initialized class will be i...

Can't commit to Subversion from NetBeans

When I change some interface things in Java, like the contents of a menu item, and save them, the commit option does not enable. NetBeans does not know that changes have been produced so I cannot commit them. How can I commit them? ...

Who has a functional build.properties file for building Eclipse 3.5M6 under OS X?

I want to take a stab at tinkering with an Eclipse standard functionality so I would like to build Eclipse under OS X 10.5. I have downloaded the source bundle, unpacked it, and found that I need to fill out a build.properties file which I have done like (with Java 6 as the default JVM) J2SE-1.4=/System/Library/Frameworks/JavaVM.framew...

Java stack trace on Windows

I need to get a stack trace for a JVM process running on a client machine that uses windows. The client has the JRE installed but not the JDK. I want to use JStack but it is not installed and we can't install a JDK on the client's machine. I also tried using AdaptJ stack trace product from a Java Webstart Session but that didn't work...

Best way to serialize a C structure to be deserialized by Java, etc.

Currently, I'm saving and loading some data in C/C++ structs to files by using fread()/fwrite(). This works just fine when working within this one C app (I can recompile whenever the structure changes to update the sizeof() arguments to fread()/fwrite()), but how can I load this file in other programs without knowing in advance the sizeo...

Selenium fails to kill browser when test fails

How do I setUp selenium to kill the test browser page on occasions where test fails. Currently, when running selenium test cases and a test fails, the browser page stays open and that causes problems when large number of tests is failing. Interestingly enough, it isnt the case when the test passes. Any suggestion?? ...

Detaching editor in eclipse

Is there a way to detach an editor from the main eclipse window? I know this is possible with netbeans but so far I haven't been able to figure out how to do it (if possible) with eclipse. ...