java

using synchronized in Threads

What could be the understanding of the following? I have gone through this post at SO but still at a loss to assemble it. code1: synchronized(this){ // some code } code2: Object lock = new Object(); synchronized(lock){ // some code } Any tutorial, or some links to explain synchronized like they explain it to a child? ...

Detect if certain software is installed on a user's machine in Java

Hi, I have a Java application which requires certain software (one of them being Perl) before it can be run. What I used to do to detect for Perl is: Runtime.getRuntime().exec("perl Test.pl"); and if there was an IOException declare that there was no Perl. However, one of my users complained that the app kept failing because he had ...

Get current active window's title in Java

I am trying to write a Java program that logs what application I'm using every 5 seconds (this is a time tracker app). I need some way to find out what the current active window is. I found KeyboardFocusManager.getGlobalActiveWindow() but I can't get it to work right. A cross platform solution is preferable, but if one doesn't exist, the...

Java : How to sort an array of floats in reverse order ?

I use the following lines to sort an array of floats in reverse order, but I got an error message, what's wrong ? float sortedData[]=new float[100]; ... Arrays.sort(sortedData,Collections.reverseOrder()); Error : cannot find symbol symbol : method sort(float[],java.util.Comparator) location: class java.util.Arrays Arrays.s...

Java temp files and automated deletion

It is safe to use java's createTempFile method to create a temp file and then rename it and keep it as a permanent file? Or does java or the system in some way keep track of its temporary files and delete them at some point? btw..this is related to Mac OS X specifically. ...

replacing a particular pattern in a string with an auto incrementing number

I have a string like "Hello how Hello are Hello" I want to replace the number of times "Hello" occurs in the above string by an autoincrementing number. Like "1 how 2 are 3" "Hello" can occur any number of times ...

Can't find service method in Netbeans J2EE project

In NetBeans 6.7.1, I have made a j2ee project, In this project I have Servlet that extends HttpServlet, Of whatever little I know about servlets, they should have a service method however in the class in NetBeans I find only thefollowing methods. protected void processRequest(HttpServletRequest request, HttpServletResponse response) ...

servlet for implementing socket connection

How do I implement a web application with a Servlet that is listening on a port for socket connections? ...

Java LoadLibrary UnsatisfiedLinkError, though Java can see the file and runs on another computer

Hi All: This problem is really befuddling me and hopefully someone could help me out. I've written some plugin libraries for a large java software. Everything works fine and well on my development computer. However, after I compiled and wrapped the software in Nullsoft Installer and install onto another computer, everything but the nat...

Android problem with saving state

I've implemented an onSaveInstanceState function in the main activity of my TabHost-based application. I need to save the state of various objects I am keeping in memory that I have all marked as serializable, as well as some basic int and string values. I have stepped through my application and watched it call the onSaveInstanceState fu...

Desktop application help framework

Consider the requirements for embedding help in a Java desktop application (or applet): Single source for content (such as AsciiDoc) to generate high quality PDF manuals1 Hooks for context-sensitive help Robust, simple, and well documented API (under an hour to learn) Small footprint (a sub-100K Java archive)2 Integrate as a docked MDI...

In java Can objects be created with both static memory allocation and dynamic memory allocation?

In java Can objects be created with both static memory allocation and dynamic memory allocation? ...

Considering moving to .NET from java

Hello, I am a 4th year computer science student, at university alot of my projects were Java based so I am pretty used to the language, platform and apis. However for a long time, I have been reading alot regarding the .net platform improvements and it's large career opportunities (at least in my country). Now I am considering shifting t...

Java built-in XML

Does Java have a built in XML library for generating and parsing documents? If not, which third party one should I be using? ...

Java simple encryption

I would like to encrypt a textual (configuration) file stored on disk. Trying to use DES encryption I've had fatal error on client machines, I later found out the algorithm could not handle accented characters (!) I suspect that was because I was using old packages (sun.misc.BASE64Decoder) - but I'm not sure that is the reason. However,...

jax-ws: setting Content-Type of request

Hi. I've been trying to consume a .net WCF rest service using JAX-WS lately. Due to security of the service, I've have to set a custom HTTP header Authorization with some signature in it. This I've solved by doing something like this: BindingProvider bp = (BindingProvider) port; bp.getRequestContext().put(MessageContext.HTTP_REQUEST_HE...

Fibonacci Heap Issue

I've been working on a Fibonacci Heap implementation in Java for about a week now. It's the implementation based off of the CLRS book. I wanted to see if I would get any performance boost using it in a side project I'm working on compared to Java's default PriorityQueue. [The default implementation in Java is array based, so much more l...

Easiest to code algorithm for Rubik's cube?

Edit: I should rephrase this, what would be a relatively easy algorithm to code in Java for solving a Rubik's cube. Efficiency is also important but a secondary consideration. Orig: What is the easiest algorithm to code for solving a Rubik's cube? It could be the least efficient but I am looking for something easy to code right now. ...

Java StackOverflowError when compiling a clone method

There are classes: InterfaceInterval<C extends Comparable<C>, I extends InterfaceInterval<C, I>> extends Comparable<InterfaceInterval<C, ?>> AbstractInterval<C extends Comparable<C>, I extends AbstractInterval<C, I>> implements InterfaceInterval<C, I>, Serializable, Cloneable AbstractTimeInterval<I extends AbstractTimeInterval<I>> exten...

Unique computer identification @ Java Applet

I have a task to create an "anti-cheat" system for a gaming website. They have problems with people joining, cheating, getting ip-banned and just uses proxies to cheat again. So my task is to build an Java applet to get the mac address from the network card, or the motherboard serial number or something like that to avoid people bypassi...