java

Can I force java to throw an error when dividing by zero with floating point numbers?

I wrote a simulator that has some collision detection code and does a good bit of math on each object when it detects collisions. If these two objects are at the exact same location or in some rare other cases, I'm getting NaN (not a number) as their location somewhere along the line and I'd like to know where. Normally, the program w...

What is numeric promotion?

Can any one tell what is numeric promotion? ...

Tree construction from an ordered list

In java, im creating a SortedSet from a list which is always going to be ordered (but is only of type ArrayList). I figure adding them one by one is going to have pretty poor performance (in the case for example of an AVL tree), as it will have to reorder the tree a lot. my question is, how should i be creating this set? in a way that ...

Android download binary file problems

Hello, I am having problems downloading a binary file (video) in my app from the internet. In Quicktime, If I download it directly it works fine but through my app somehow it get's messed up (even though they look exactly the same in a text editor). Here is a example: URL u = new URL("http://www.path.to/a.mp4?video"); HttpURLCon...

JPA Implementations - Which one is the best to use?

Hi all, I have made use of the following JPA implementations: Hibernate, Toplink, OpenJPA Each of them has their own strengths and weaknesses. I found Hibernate the most advanced of the three except that it mixed some of its own enhancements with JPA which made it difficult to switch out to other providers. Most importantly, its que...

Alternatives for JCIFS NTLM library

Are there any alternatives for JCIFS NTLM library? ...

How do I fill arrays in Java?

I know how to do it normally, but I could swear that you could fill out out like a[0] = {0,0,0,0}; How do you do it that way? I did try Google, but I didn't get anything helpful. ...

Have you used Quickcheck in a real project

Quickcheck and its variants (even there is one in java), seems to be interesting. However, apart from academic interest, is it really useful in a real application testing (Eg. a GUI application or Client/Server or even take StackOverflow itself)? Any experiences you had with similar test generators is appreciated. ...

HashMap gets over written every time I use .put()

My application is related to the stock market. I have a feed that is consistently updating an object called Price. Price has a HashMap that stores the security code (String) and price (Double). Every time a new price comes in this object is updated. The application is supposed to scan the prices for large moves. I have a separate class ...

How do I intercept a method invocation with standard java features (no AspectJ etc)?

I want to intercept all method invocations to some class MyClass to be able to react on some setter-invocations. I tried to use dynamic proxies, but as far as I know, this only works for classes implementing some interface. But MyClass does not have such an interface. Is there any other way, besides implementing a wrapper class, that d...

Using log4j logging in weblogic 9/10

In weblogic I can configure in the console for the Serverlog to use log4j instead of default JDK logging. However the serverlog is not using a log4j.properties file, but seems to use the configuration in config.xml Even if the log4j.properties file is in the classpath and I set these properties: set JAVA_OPTIONS=%JAVA_OPTIONS% -Dlog4j....

jpeg to pdf java library

Do you know of any jpeg to pdf, open source if possible, library for Java? ...

Building a tree in Java

I'm a newbie in Java. I want to build a tree with one root node and multiple children nodes with some weight on each branch. Can somebody help me in this. ...

class loader

Hi all, I'm having problem with class loaders. All the time. Sometimes it works, sometimes it doesn't work. When I started I've tested this works but not from *.jar: URL url = AcAnalyzer.class.getResource("../stuff/resource"); //and this works even from jar file: URL url = Acnalyzer.class.getResource("/stuff/resource"); URL url =...

Easy way to get a subset of the keyset of a TreeMap (in Java)

Is it possible to extract the top n (I use top because I believe a TreeMap is sorted) key elements from a TreeMap, without iterating using an Iterator object. I can do the iteration but it's tedious to have to check for nulls etc. ...

Does anyone know a java component to check if IP address is from particular network/netmask?

I need to determine if given IP address is from some special network i must authenticate automatically. ...

"Missing artifact" errors with company repository

I setup a company maven repository using artifactory. I deployed a project of us into the repository. If I now specify a dependency to that artifact, it doesn't get retrieved. Which it should, because I declared this in my settings.xml: <mirrors> <mirror> <id>company-internal</id> <name>company repository</name> <url>http:...

context class loader

What is the difference between? Class.getClassLoader() and Thread.getContextClassLoader()? ...

Using the keyword "this" in java

I'm trying to get an understanding of what the the java keyword this actually does. I've been reading Sun's documentation but I'm still fuzzy on what this actually does. ...

How can I index a lot of txt files? (Java/C/C++)

I need to index a lot of text. The search results must give me the name of the files containing the query and all of the positions where the query matched in each file - so, I don't have to load the whole file to find the matching portion. What libraries can you recommend for doing this? update: Lucene has been suggested. Can you give m...