java

High performance serialization: Java vs Google Protocol Buffers vs ... ?

For some caching I'm thinking of doing for an upcoming project, I've been thinking about Java serialization. Namely, should it be used? Now I've previously written custom serialization and deserialization (Externalizable) for various reasons in years past. These days interoperability has become even more of an issue and I can foresee ...

Plugin GMF

Comment une image devient un noeud dans la palette et on peut l'inserer dans la zone de dessin translation: How a picture becomes a node in the palette and can be inserted in the drawing area ...

Do you plan to use the Scala programming language and on what project?

Where do you seen using Scala for your project? ...

The device is not connected exception

I try to open a large number of files but after 5000 files or so I get Exception in thread "Main" java.io.IOException: The device is not connected Is this the expected behavior? Is there a way around it? I want to leave my code as straightforward as possible. ...

Java Application Architecture Guide

Is there a Java Application Architecture Guide that is a counterpart of this: http://www.codeplex.com/AppArchGuide ? ...

java service and resource sharing

Hi everyone, I am creating a windows service in Java that writes data to an object. This object has to be accessible by another Java program. What is the best approach to take? Thank you. Jack ...

How to use a bitwise operator to pass multiple Integer values into a function for Java?

In application frameworks I keep seeing frameworks that allow you to pass in multiple Int values (generally used in place of an enum) into a function. For example: public class Example { public class Values { public static final int ONE = 0x7f020000; public static final int TWO = 0x7f020001; public sta...

Changing volume in Java when using JLayer.

I'm using JLayer to play an inputstream of mp3 data from the internet. How do i change the volume of the output? I'm using this code to play it: URL u = new URL(s); URLConnection conn = u.openConnection(); conn.setConnectTimeout(Searcher.timeoutms); conn.setReadTimeout(Searcher.timeoutms); bitstream = new Bitstream(conn.getInputSt...

Explain the generics used in the Enum declaration

Can someone please explain what this means? Enum<T extends Enum<T>> This seems like a circular definition, and I find it highly confusing to say the least. ...

Merge Two XML Files in Java

Hi All I have two XML files of similar structure which I wish to merge into one file. Currently I am using EL4J XML Merge which I came across in this tutorial. However it does not merge as I expect it to for instances the main problem is its not merging the from both files into one element aka one that contains 1, 2, 3 and 4. Instea...

java reference file at same level as jar

Fixed the problem with the following code - not the most gracious way - but i need a quick solution for this assignment package six.desktop.gui.common; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.URL; public class Config { private static final String configFileName =...

How do you repeatedly call a Thread in Java?

I want a thread to execute in the background every 500 milliseconds. To do that, I extended a Thread, implemented ActionListener and put the class that I extended into a Timer. The Timer calls run() every 500 milliseconds. However, my whole Swing GUI freezes up when this thread is downloading stuff from the Internet. I want it to run in ...

Can I stop JTree caching nodes (in a file system tree)?

I have a JTree implementation for directories in the file system. The problem I have is that when a directory is removed or renamed, the tree still shows the directory in it's parent. The parent tree seems not to be updated for any changes once a node has been expanded. The model I have written does not cache (I have commented out what...

Java Unsigned Char Array

I'm working on a project fuzzing a media player. I wrote the file generator in Java and converted the CRC generator from the original compression code written in C. I can write data fine with DataOutputStream, but I can't figure out how to send the data as an unsigned character array in java. In C this is a very straightforward proces...

Java dynamic binding

I am practicing for an exam, and found a sample problem that gets me totally lost. For the following code, find what the output is: class Moe { public void print(Moe p) { System.out.println("Moe 1\n"); } } class Larry extends Moe { public void print(Moe p) { System.out.println("Larry 1\n"); } public v...

Random Number Generator

I need to write a program in Java to generate random numbers within the range [0,1] using the formula: Xi = (aXi-1 + b) mod m assuming any fixed int values of a, b & m and X0 = 0.5 (ie i=0) How do I go about doing this? i tried doing this but it's obviously wrong: int a = 25173, b = 13849, m = 32768; double X_[i]; for (int i = ...

How do I specify host and port when accessing a web service from JAX-WS-generated code?

I have a WSDL file for a web service. I'm using JAX-WS/wsimport to generate a client interface to the web service. I don't know ahead of time the host that the web service will be running on, and I can almost guarantee it won't be http://localhost:8080. How to I specify the host URL at runtime, e.g. from a command-line argument? The ge...

How to get an InputStream from a BufferedImage?

How can I get an InputStream from a BufferedImage object? I tried this but ImageIO.createImageInputStream() always returns NULL BufferedImage bigImage = GraphicsUtilities.createThumbnail(ImageIO.read(file), 300); ImageInputStream bigInputStream = ImageIO.createImageInputStream(bigImage); The image thumbnail is being correctly generate...

content not allowed in prolog exception

I am trying to send xml to a java-based web service given to me by a thrid party via a c#.NET application, and I get the "org.xml.sax.SAXParseException: Content is not allowed in prolog" error. I have verified the xml against the schema, and I passed the memorystream I am using to hold the xml to an .xml file, then opened the file with...

How to link lwjgl dll with launch4j

Hey all, I am trying to wrap my jar as an exe using launch4j. However I am using the lwjgl library and having trouble linking the native dll's. My directory structure is as follows: I have a top directory which contains the following path: top/lib/lwjgl/native/win32 where my lwjgl dll's are contained. There is also a dist directory th...