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 ... ...
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...
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...
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?
...
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...
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 ...
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...
Possible Duplicate:
add values to enum
Why enums in Java cannot inherit from other enums? Why is this implemented this way?
...
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...
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 " +
...
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...
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....
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?
...
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 ...
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!
...
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...
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!
...
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
...
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 =...
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(“...