java

Sometimes the packets are only transmitted after the process is ended? [Java]

I have an application which opens a datagram sockets and sends to various other processes .... sometimes this application lauches another process (using ProcessBuilder) which also does some network communication... Now, the joke is, the launched process will "sometimes" only recieve messages after the main application is terminated ... ...

Handle into eclipse's parsing of java code?

How does eclipse internally build its internal representation of java code in order to be able to detect things like unreferenced methods, or to find method references in a project? And is there any way to get a hook into that information to build tools based on eclipse's internal parsing, Whether as an eclipse plug-in or as a standalone...

Java doesn't follow redirect in URLConnection

Hi everyone, I can't understand why Java HttpURLConnection doesn't follow redirect. I use the following code to get the page http://bit.ly/4hW294: import java.net.URL; import java.net.HttpURLConnection; import java.io.InputStream; public class Tester { public static void main(String argv[]) throws Exception{ InputStream i...

Merging XML save files

My Java application's save files are in XML, and in certain cases, a user might want to merge two save files together. What packages have people used to do this? Any caveats to offer? ...

Dynamically add a servlet to the servletConfig

Hi All I have a Java web application that uses a plugin architecture. I would like to know if anyone has a solution where by one could add a servlet, with serlvet mapping to the servletconfig while the web app is running? The idea being that a class could be added to the /WEB-INF/classes folder and be made active as a servlet without re...

How is C# inspired by C++ more than by Java?

When looking at the history of C#, I found out that C# was seen as an update to C and/or C++. This came a bit as a surprise to me, as on the surface, I see much more common ideas between C# and Java (Garbage collection comes to mind). I don't write code in Java, but I have usually no problem following Java code, and routinely read books ...

NetBeans: Specifying html for Applet which uses JSObject for debugging

I would like to specify html for my applet and debug it in NetBeans. The helpful is following: My applet class is MainApplet. I put MainClass.html in the same folder with MainApplet.java. After this I run applet via right click on file in NetBeans and selecting Debug "MainApplet.java". It looks like applet tag from MainApplet.html is us...

Java enum inheritance

Possible Duplicate: add values to enum Why enums in Java cannot inherit from other enums? Why is this implemented this way? ...

JSR 330 and Guice interoperability

Does anybody have experience with JSR 330 vs Guice? From what I gather Guice is not an implementation of JSR 330 but if it is anything like Hibernate and JPA the implementation supports a bunch of additional functionality no in the API. Since I am already using GWT-Dispatch, Warp-persist guice-serlvet, etc would there be anything gaine...

Java ArrayList not allowing me to add from outside constructor

public class Start { public Register theReg = new Register(); public static Start go = new Start(); public static void main(String[] args) { Register theReg = new Register(); go.regUsers(); if(theReg.logIn("jsmith","password")) { System.out.println("You're logged in as " + ...

Modifying this 8-puzzle code to print the intermediate states to reach the solution

About the 8 Puzzle Problem // Breadth First Search Usage in the common Eight Puzzle Problem. import java.util.*; class EightPuzzle { Queue<String> q = new LinkedList<String>(); // Use of Queue Implemented using LinkedList for Storing All the Nodes in BFS. Map<String,Integer> map = new HashMap<String, Integer>(); // HashMap...

iterating over and removing from a map

I was doing: for (Object key : map.keySet()) if (something) map.remove(key); which threw a ConcurrentModificationException, so i changed it to: for (Object key : new ArrayList<Object>(map.keySet())) if (something) map.remove(key); this, and any other procedures that modify the map are in synchronized blocks....

Most suitable database package for use with JADE

Hi, I'm using JADE (Java Agent DEvelopment Framework) and need to set up a database back end. Does anyone have any recommendations for which database system would work well with the framework? ...

JComboBox adds items for one ArrayList of strings, but disappears from GUI for another

I have 2 JComboBox components added to my GUI productComboBox and categoryComboBox, with the following item listeners defined for each: categoryComboBox.addItemListener(new GoItemListener()); productComboBox.addItemListener(new ProductItemListener()); The user first selects a product, and then the listener should populate the ...

Those geometric icon avatar thingies

Possible Duplicate: what is the algorithm used to generate those little gravatar identicon images? Nobody I know seems to know where to find some code (preferably Java) to autogenerate those geometric avatar icons, such as used here on StackOverflow. Anyone have a source or can point to some working code? Thanks! ...

Using the keySet() method in HashMap

I have a method that goes through the possible states in a board and stores them in a HashMap void up(String str){ int a = str.indexOf("0"); if(a>2){ String s = str.substring(0,a-3)+"0"+str.substring(a-2,a)+str.charAt(a-3)+str.substring(a+1); add(s,map.get(str)+1); if(s.equals("123456780")) { System.out.println("The sol...

How do I find out Java's heap size on my computer?

Hello, I'd like to be able to get the size of the heap as a variable. I don't need to change the size, just know what it is and have it in a variable. Thanks! ...

How to clone a CharArrayWriter?

In Java 1.5, how can I clone an instance of java.io.CharArrayWriter? CharArrayWriter x = new CharArrayWriter(200); x.write("foo bar bob"); CharArrayWriter y = x.clone(); // Object.clone() is not visible!! Thanks, mobiGeek ...

Attempting to set transparency in an imported bmp image

Looking at a previous response to a similar question to this, I developed this code: public static BufferedImage getImage(String imagefile) { BufferedImage image = null; try { image = javax.imageio.ImageIO.read(new java.io.File(imagefile)); int trans = image.getRGB(0,0); final int width = image.getWidth(); int[] imgData =...

Which is optimal ?

Is declaring a variable inside a loop is good or declaring on the fly optimal in Java.Also is there any performance cost involved while declaring inside the loop? eg. Option 1: Outside the Loop List list = new ArrayList(); int value; //populate list for(int i = 0 ; i < list.size(); i++) { value = list.get(i); System.out.println(“...