java

How to implement an unsigned 64-bit int in Java using BigInteger class?

I am looking for one datatype with exact capacity of 0 to 2^64 - 1. We know that Java as it is does not support 'unsigned' barring char datatype. There is BigInteger class that allows creation of larger numbers that long datatype cannot support. But I am not sure how BigInteger class would serve my purpose. BigInteger class allows assi...

Is there a Swing hack to query or set Z-order of a window?

We are trying to save the state of the application on exit and restore it on startup. Part of the state is the relative Z-order of all JFrames. Unfortunately, Swing doesn't seem to provide any method to learn or set Z-order of a Window (even relative to other windows in the same VM). We deal with setting the Z-order by calling toFron...

Embeddable Java HTTP Servers

There seems to be multiple extremes when supporting embeddable Java HTTP servers. I have seen minimalist approaches such as NanoHTTPD and leveraging the com.sun.net.httpserver package to attempting to embed Jetty and Tomcat. The ideal embeddable HTTP server would be implemented such that it could be launched via Executor and come with Se...

Occurences of substring in a string

Why is the following algorithm not halting for me? (str is the string I am searching in, findStr is the string I am trying to find) String str = "helloslkhellodjladfjhello"; String findStr = "hello"; int lastIndex = 0; int count =0; while(lastIndex != -1){ lastIndex = str.indexOf(findStr,lastIndex); ...

Database Migration

I am working on database migration tool in java. The tool is copying database tables with their data's to the destination database. But i want it to work on different databases. Copy from mysql and create in derby etc. With JDBC, we can gather enough information about the table and its columns. But i am going to ask this, if i can recrea...

API to programmatically refactor Java code

Do you know an API to programmatically refactor Java code. Preferably: easy to use support for rich refactorings ...

Avoiding in-place pointcut expression in Spring AOP

Hi, I'm using Spring AOP. I'm giving my pointcuts like: @Pointcut("execution(* com.demo.Serviceable+.*(..))") public void serviceMethodCalls() { } Is it possible to avoid the in-place pointcut expression in Spring AOP? Thanks, Veera. ...

Maintaining a database externally in a text file

hi all, What is the simplest way of maintaining a txt based database file that allows the program the write in new or edit existing entry during execution time. to be specific, the program must be capable of storing a client, ip and port when it logs in, and remove accordingly when the client logs out, without using "internal" approac...

Best way to prepare for the Upgrade Exam: Sun Certified Programmer for the Java Platform, Standard Edition 6 (CX-310-066)

I'd like to take the Java Certification Upgrade exam for Java 1.6. I'm certified in Java 1.2. What would be the best way to prepare for this exam? Upgrade Exam: Sun Certified Programmer for the Java Platform, Standard Edition 6 (CX-310-066) ...

How to check whether JavaScript is enabled in client browser using Java code

Hi, can anyone help me in trying to check whether JavaScript is enabled in client browser using Java code. Thanks in advance ...

How do I play a wave file sent from server?

Hi, I send a wave file using a client and server method. How could I play this file on the client once it's received? This is the server code used to send the wave file: import java.lang.*; import java.io.*; import java.net.*; class Server { //D:\Documents and Settings\Desktop\gradpro\test1 static final String OUTPUTFILENAME = "...

Java to access pci-modem

Hi, I have a pci-modem in my laptop and I tried to run a program that opens the port and configures it.I get an excepcion while doing it, I think that it can't see the port, even though it is on COM3. Is there any way of doing it in java? The error I get is noClassDefFoundError. It says the SerialPortEventListener class isn't found. I...

In Java, is it safe to assume a certain size of the primitive types for bitwise operations?

Given Java's "write once, run anywhere" paradigm and the fact that the Java tutorials give explicit bit sizes for all the primitive data types without the slightest hint that this is dependent on anything, I would say that, yes, an int is always 32 bit. But are there any caveats? The language spec defines the value range, but says nothi...

Recommendations for Handwriting Recognition Libraries/Packages in Java

Finding a good Handwriting recognition library in Java has been a bit elusive. I'd like to compare both commercial and any free options, along with any insights to strengths/weaknesses of each. Thanks in Advance. ...

Java applets with hardware accelerated 3D graphics? OpenGL and/orDirectX

I can't find a clear answer to this question with all my googling. If I want a web applet, is there a library in Java that takes advantage of the hardware accelerated graphics drivers on the client's machine, as in OpenGL and directx? I'm picturing writing some driver detection code before the applet launches to detect 3D graphics capa...

Hosting for javadoc?

I have an open source project hosted on bitbucket. Bitbucket does not provide hosting for large number of small files (i. e. javadocs). Where could I publish javadocs? Javadocs must be browseable, not as single archive. ...

Why might gwt be getting more popular?

I've noticed a dramatic increase in GWT popularity during the past 6 months. More evidence can be seen here: http://www.indeed.com/jobtrends?q=gwt&l= Can someone explain the cause? ...

How to take previous value during refresh of a servlet

I hava a servelt. I am using the following code to refresh. res.addHeader("Refresh", "10"); But before I am reading the date using a form. For the first time, it works fine. But after 10 sec, during refresh I am getting null pointer exception as date is null. How to take the previous value of date even after refresh. thanks in adva...

Java: how to handle a LOT of fields and their encapsulation cleanly?

Let's say I am tasked with coding some kind of an RPG. This means that, for example, I'll want to track a Character GameCharacter and stats thereof, like intelligence, damage bonuses or hitpoints. I'm positively scared that by the end of the project I may end up with handling with very a high number of fields - and for each I would have...

[Java] getting strange results from framerate code

I'm trying to keep my game at 60fps, but I'm getting strange results from my code like "2-8000 fps" Why isn't this staying at 60? public static void main(String[] args) { joglplat m = new joglplat(); while(true){ long startTime = System.nanoTime() / 1000000; try { // 12345...