Java-index »» Core »

Why is ArrayList iterator fail-fast

116 byte By relaxedgalaxya at 2007-11-27 6:34:50
Why cant we add objects to an ArrayList after the ierator() method has been called, but in LinkedList we can?

java.security.AccessControlException: access denied

4285 byte By Tamimia at 2007-11-27 6:35:28
Hello, I'd created a Jsp file that require an ECHO service from RMI server, the contents of my jsp file is:<%@ page session="false" import="pack.jsp.*, java.rmi.Naming.*, java.rmi.*, java.security.*;"%><body bgcolor="white">JSP TEST2<%try { ...

Storing file contents in a Collection

1505 byte By iketurnaa at 2007-11-27 6:36:20
Hi All,Im trying to read a csv file, break the lines by comma, then store them and sort them.I have the test code working from: http://java.sun.com/docs/books/tutorial/collections/interfaces/order.htmlI am reading the file, but when I System.out.println() I keep getting the last line of the ...

Proposal: Extending @Target

1950 byte By McNeppa at 2007-11-27 6:36:42
I'd like to share my idea of extending java.lang.annotation.TargetHere's an example that illustrates what I'm thinking of:I have designed a class Enumerable that is a kind of "extendable enum" class, making it possible to register instances of a derived class with their superclass. (It is ...

Model to bind to multiple sockets

1400 byte By DwightKa at 2007-11-27 6:37:23
Hello,I have a program that is comprised of 3 tiers: client, gateway, application server.I am trying to achieve the following:The client opens a connection on port 80Gateway accepts the connectionGateway determines which application server is handling this clientGateway opens a client ...

Sockets and Channels?

793 byte By sim085a at 2007-11-27 6:38:00
Hi,I have just completed the chapter about 'Channels' in the book I am reading. I was completely new to these since I had never seen them or heard of them before! Thus I am feeling quite confused on when these should be used and why!Basically each time I asked networking question I always got ...

Why System.in is blocking other IO call

2177 byte By ashoknanashoka at 2007-11-27 6:39:13
I was trying this simple program to run some test...package com.jpmc.ibtech.hycee.base;import java.io.IOException;public class TestThread {/** * @param args * @throws IOException */public static void main(String[] args) throws IOException { (new Thread() {public void run() {try {sleep(8000); ...

How to communicate asynchronously with client/server?

1428 byte By iofthestorma at 2007-11-27 6:39:43
Hi, I've been working on a client/server project based off of the KnockKnock Server/Client example (multiclient one) and I'm wondering how I can make it so that both sides don't wait around for input before doing anything else. Currently, since I've followed the example and done something ...

Compile-time business rules

854 byte By developer_jbsa at 2007-11-27 6:40:14
using apt i have embedded compile-time checks for particular relationships, e.g. AnnotationA exists (only) on ClassB, AnnotationC exists on subclass of ClassD, ClassE has 0..n refs to ClassF, ClassG declares AnnotationH, ClassI has 0..n fields/methods annotated (by), etc.with a declarative ...

Thread design comments

6899 byte By anand_nalyaa at 2007-11-27 6:40:31
Hi,I've designed this small application. I want to know if there are some chances of race conditions, deadlocks or memory leaks in it. Please give your comments.The problem is that I need to do some task that takes about 3 minutes to complete. The same task can be submitted by multiple ...

Arrays.sort() performance

253 byte By HEMANT-DONa at 2007-11-27 6:40:34
Hi all,I am using the Arrays.sort method to sort files by their size.I am using a size comparator to do this.I would like to know how efficient could this be assuming large file sizes.Thanks & Regards Hemant

Problem in NIO server....

10046 byte By JDvlpra at 2007-11-27 6:40:45
I have written an NIO server which gets data from a Static queue and sends it to the clients... (this is my intention.. but the server doesn't)...The problem is the server sends data to one client... and if another client is connected, the server sends data to the latest client and stops ...

Recommend Data structure? multi-map?

1440 byte By lokiea at 2007-11-27 6:41:14
Hello everyone.I'm not sure what data structure I should use for my particular problem.This is whats going to be happening.I'm writing a SocketServer, its going to be receiving 1000's of strings of random length. Each string is going to have an integer which can be any number, for instance ...

How to monitor a file?

259 byte By youhaodiyia at 2007-11-27 6:41:36
I want my program to monitor a file or directory. whenever the file or the directory is modificated, it will send an event to my program.I use a thread to check the last modification time ever 5 seconds, but i don't think this is a good design.

How to change my ip address

89 byte By kim@skya at 2007-11-27 6:41:52
Hi,any one can help me to change my ip address using java instructions. plz

Defining relationship between a Map's keys and values

1678 byte By chopsueysenseia at 2007-11-27 6:42:10
Hi.I'm trying to solve a problem using generics, but I cannot seem to make it right. What I want is to define a relationship between a map's keys and values using generics.The idea is to have a mapping of events of various types to event handlers. For instance given the interface:public ...

Socket based application - Performance Issues - Suggestions Needed

2878 byte By akhilnagpala at 2007-11-27 6:42:16
Hi All,We have an application which basically has been developed using core java. Here is a high level information about the application:a) It opens a serversocket which allows clients to connect to it.b) For every new client connection, a separate thread is created and this thread deals with ...

Recommend book for java networking?

440 byte By lokiea at 2007-11-27 6:43:24
Hello everyone.I was wondering if anyone really found a nice book on Java network programming. I just started a co-op and over the last 4 weeks I've been teaching myself Java from a C++ background. But I haven't been able to find many resources online that really went into detail. They are ...

Timeout in URLConnection

491 byte By escobar5a at 2007-11-27 6:43:43
Hello, i have a problem,i have an URLConnection to send some data from an applet to a servlet, i need NOT to have timeout but the connection is giving me a timeout, i'm using java 1.5 so i did this:URLConnection servletConnection = ...

HTTP DELETE method on IIS using HttpURLConnection

329 byte By DipakMehtaa at 2007-11-27 6:43:54
Hi,I want to send HTTP DELETE request using HttpURLConnection to remove a file from the IIS web application. I do have write access to IIS web application. But I am getting http error code : 501 ( NOT IMPLEMENTED ). Is there a way to enable HTTP DELETE on IIS ?Regards,Dipak ...

Finding java packages available in a jar file..

581 byte By chaos_begins_herea at 2007-11-27 6:44:12
Hi All,I need to find the java packages available in the jar file. I thought of doing this like this. I traverse through the directory, and if a directory has a .class file, then i can form the package structure by finding the parent. But the problem is ZipEntry doesn't seem to have any method ...

NullPointerException GZIPOutputStream

725 byte By Johannesa at 2007-11-27 6:44:13
Does anyone know, why I get a NullPointerException in the linewhile (length = in.read(BinaryBody)) != -1)?byte[] BinaryBody = new byte[8192];InputStream in = method.getResponseBodyAsStream();GZIPOutputStream gzipOut = new GZIPOutputStream(client.getOutputStream());int length;while ((length = ...

Error about Source Level only if 5.0? I'm using Java 1.6? Maps

3453 byte By lokiea at 2007-11-27 6:44:20
Hello everyone. I was just trying to run some simple Source Code from my book here:package mapa;import java.util.HashMap;import java.util.Map;import java.util.Set;public class MapTest {Map<String, String> phonebook = new HashMap<String, String>();// constructorpublic example2(String ...

How do u read the hs_err_pid<pid>.log file

11744 byte By adarsh227a at 2007-11-27 6:44:46
Hi,When using hprof or any profiling tool, the hotspot vm crashes and generates the following file. How do we read this file or make any sense of it. Is there any utility, etc..We are using hotspot jvm 1.4.2_12. Any help will be appreciated. BTW here is the latest hs file. ## An unexpected ...

HTTP 100 being treated wrong?

851 byte By mdwarnera at 2007-11-27 6:45:02
A project I am working on was getting a socketClosedException so when doing a packet trace we saw that the last packet before the exception was an HTTP 100. We noticed it was using IIS 5.1 when previous testing had been done on IIS 6.0. As a test, we tried using jrockit, which was being using ...

runnign through a proxy

3887 byte By xpyro_666xa at 2007-11-27 6:47:06
import jav.net.*;import java.io.*;import java.util.*;import java.awt.*;import javax.swing.*;import java.awt.event.*;public class inet extends JFrame implements ActionListener{public JButton ok;public JTextField host, ip;public JPanel prim;public JLabel ho, i;public inet(){ok = new JButton("find ...

Am I not flushing enough? echo server, works if its all in 1 main function

8540 byte By lokiea at 2007-11-27 6:47:23
Hello everyone...odd problem. I just broke up this code into classes so its not all in main() but now its not working properly.Before I did this, I could telent into whatever port the serversocket was binded to, like: telnet localhost 8008 and I could type in a message, it would spit out the ...

File Write Protected | sorry if this is the wrong forum

578 byte By mazikowskia at 2007-11-27 6:47:24
I am writing an address book and when you change the name of a contact, the old file needs to be deleted. I am writing this using eclipse running on an Ubuntu 6.06LTS box. When I try to delete the file using .delete(), it is unable to. Using .canWrite() returns the file as being write ...

open file error.

1770 byte By Holoda at 2007-11-27 6:49:04
This is my method:private static BufferedReader readFileWithBufferedReader(String filename){FileInputStream fis = null;InputStreamReader sr= null;BufferedReader r= null;try {fis = new FileInputStream(filename);} catch (FileNotFoundException ex) {ex.printStackTrace();}//fis catchtry {sr = new ...

NIO How to send many requests to a site,using(opening)only one connection?

1092 byte By nightingalea at 2007-11-27 6:49:17
Hello everybody,I begin to work with java.nio. Here is description about my program: The client open one connection to a site, using NIO ( SocketChannel, configureBlocking(false) ). After finish connection, the client send request to server and wait for read data. After reading (read to the end ...

NIO HOW to send many requests to a site, using only one SocketChannel

1064 byte By nightingalea at 2007-11-27 6:49:18
Hello everybody,I begin to work with java.nio. Here is description about my program: The client open one connection to a site, using NIO ( SocketChannel, configureBlocking(false) ). After finish connection, the client send request to server and wait for read data. After reading (read to the end ...

saving a JFrame to file is this possible?

245 byte By lantus007a at 2007-11-27 6:50:08
Hi, I am working on a hnd project which has a JFrame that contains textboxes and labels, the textboxes are filled with information from other class attributes, was wondering hoe to save the information on this screen to file.Thanks

storing objects in List<?>

297 byte By lasjaka at 2007-11-27 6:50:33
I've created a List<?> list; but when I want to add any object for ex. list.add(new Integer(5)); there's an error 'The method add(capture-of ?) in the type List<capture-of ?> is not applicable for the arguments (Integer)'How should I add objects to this kind of

1.5 "synchronized" Holds Monitor Past End of Block?

2847 byte By Dave_Lindquista at 2007-11-27 6:50:59
I've got a strange problem where a synchronized(x) appears to be holding the monitor for "x", even past the end of the synchronized code block.The basic structure of the code looks like this:Running in a "Processor" thread:(class-instance-level variable) "queue"run(){while(!stopRequested){Item ...

illegal java monitor exception

542 byte By jamesgoslina at 2007-11-27 6:51:13
hi all,i am making an application in which i am receiving live data from from server and i am storing that data into hashtable through one thread then i am reading data from the same hashtable through another thread and wans to display upon applet now the problem is that i am getting Exception ...

Sorting of a Collection

1107 byte By Rohan.Desaia at 2007-11-27 6:51:23
I have a collection of Objects of a Class, this Object contains another collection within it. i.e Class A contains a collection of Class B objs.Now I want to sort elements of Collection B and based on its probability sort collection A ......I have an object C of same type as obj B of same class ...

Bounds on type parameters of implemented interfaces.

930 byte By bungemanva at 2007-11-27 6:51:50
Lets say I'm using reflection to walk over a class' methods. I come upon a method and get its return type, lets call it "returnType". Let's say "java.util.List.class.isAssignableFrom(returnType)" is true. What I'd like to know is what is the upper bound for E in List<E> for this ...

Proper use of JVM XMs and XMx settings

206 byte By damionsteena at 2007-11-27 6:51:54
I've configured Tomcat to run with -XMs1024m -XMx1024m, and am interested to know GC performs when the -XMs and XMx are the same value.Would it generally be better to have a lower -xms value?

A higher level of JMX Notification

2296 byte By -._marco_.-a at 2007-11-27 6:51:58
Hi everybody.While JMX has a great way of communication towards the MBeans through the use of high level interfaces, the notification mechanism is only available through a pre-determined interface (the NotificatioListener) that support only the passage of some pre-determined information such as ...

Is it possible to create exception rule in Comparator sort order?

450 byte By sourceLakeJakea at 2007-11-27 6:52:56
I have been working on trying to learn how to use Comparators to sort Collections... In one of my recent experiments, I tried to order a PriorityQueue of String elements alphabetically, in ascending order, with one exception: any word beginning with the letter "z" should be given a higher ...

nasty bug: Can't locate it.

7979 byte By xpantaa at 2007-11-27 6:53:00
Hi, I am attaching some code because I am desperate.I have a ThreadedAction which is called when I click a button that brings data from a Database. The Data are inserted into a Jtable. Sometimes I get some mysterious exception I can't catch.class ThreadedAction extends AbstractAction ...

Loading a class by absolute path

809 byte By ducotta at 2007-11-27 6:53:18
So I'm making a plug-in for eclipse with which I want to automatically generate test stubs for each of the public methods and constructors of a class. The way the plug-in works, you right click on the file in the navigation pane. At this point, java has created an IResource object to store the ...

Could not map vmid to user Name

395 byte By leostar_10a at 2007-11-27 6:53:30
Hi Guys,I am running jdk1.5.0_06 on Linux. I have added the system property com.sun.management.jmxremote for my Java Application, but when I run jconsole <pid> it gives me the error:Unable to attach to 25837: Could not map vmid to user Namehere 25837 is the PID of my Java Application. I ...

what should the architecture look like?

940 byte By jelaloa at 2007-11-27 6:54:25
hi all,I am about the build a multi client application using RMI. I am not going to explain all the details but it will be something like:think about a server which all clients will try to connect in the first place. this will be a class, implementing a remote interface and accepting ...

I'm desperate :( cannot track memory leak.

1251 byte By kipodusha at 2007-11-27 6:54:34
Hello.Maybe someone can help me on this because I have tried already everything.Basically we have an application that after running about for 3 weeks it reaches a state of "Out of Memory Error" and stops functioning. I tried to compare dumps of JMAP tracking out every day that passes but ...

I'm desperate :( cannot track memory leak.

1249 byte By kipodusha at 2007-11-27 6:54:35
Hello.Maybe someone can help me on this because I have tried already everything.Basically we have an application that after running about for 3 weeks it reaches a state of "Out of Memory Error" and stops functioning. I tried to compare dumps of JMAP tracking out every day that passes but ...

Introspector (bug)?

3531 byte By kimilea at 2007-11-27 6:55:21
HiI notice a behavior in the Introspector.getPropertyDescriptors() that i qualify has a bug.The problem occurs when i create a bean that as a property with a letter in lowercase followed by one in uppercase and what ever you want next. Something like xBlalala.When using the Introspector to get ...

How can I find the currently logined domain name on Windows?

435 byte By hkDennis2000a at 2007-11-27 6:55:47
Dear,I've a program that query some user account information from A.D.But I don't want to hard code anything.I've read some previous post about using LDAP, and using DNS queries to found all LDAP server of A.D.But how can I get the A.D. domain name in Java?for example ...

Delaying 2 method calls... with Timer?

1094 byte By deoshermesa at 2007-11-27 6:55:54
Hey,I'm busy with an applet and need to delay 2 method calls.the first method needs to be executed immediately, and the other has to be executed after, say 5 seconds.Method: public void setRed(){canvas.setAmber();try {Thread.sleep(2000);}catch (InterruptedException e){e.printStackTrace(); ...

Mathematical set operations

332 byte By MagicMuscleMana at 2007-11-27 6:56:11
Hello all,every now and then I need the mathematical set operations "intersect", "unify" and "subtract". It's no big problem to implement them where needed, but I wondered if there is an official version in the Java-API. This would be especially useful in the Set classes, but I couldn't found ...