Java-index »» Core »

Thread question

626 byte By jlrockya at 2007-11-27 7:55:40
I want to parallelize a block of code, say that contains three statements: Statement 1, Statement 2, and Statement 3.I have created two threads but only one of them should execute statement 2. I mean Thread 1 should execute Statement 1 and Statement 3 while thread 2 should execute Statement 1, ...

Convert written files to a readable state

2602 byte By Dytea at 2007-11-27 7:55:46
Hi there,I created an application that writes a List<Object> to a file.It's been working fine like this, but then for some reason, this file became corrupt. I figured out why, but I haven't been able to recover the data in this corrupt file.Most important part (on position 1) of this ...

Client-Server sending files without closing sockets

8294 byte By TimmyXa at 2007-11-27 7:55:57
Hi,I Know there are many topics about this but mostly the answer were use http-something.I am trying to do this with sockets only, but my code shows up very strange behavior.It looks like the file transfer just works fine, but the client who receives the file is stuck at the end of the file ...

Selection Sort type iteration with LinkedList

1239 byte By Nialsha at 2007-11-27 7:57:59
Hi,It seems like Java's ListIterator isn't especially great for doing a "compare every element to every other element" traversion (like the type used in selection sort).For example, this code works fine:for(ListIterator<T> i = list.listIterator(); i.hasNext();) {T a = ...

Facing problems with URLConnection under high load

1189 byte By RahulSachdeva at 2007-11-27 7:58:07
Hi,I have a piece of code that acts as a load balancer. Under high load scenario - 200+ different simulataneous users, it throws some errors.Following is a snippet from that code - URL url = new URL(site);URLConnection urlconnection = ...

How to access UPS information

259 byte By solve_my_buga at 2007-11-27 7:59:21
Hi everyone...Is anyone aware, how to interact with UPS (Uninterrupted Power Systems) in Java? I think it is as similar as to interact with remote computer in the network? If anyone knows please reply to the post.Thank You !

properties of a cd

346 byte By marty147a at 2007-11-27 8:01:16
Hiim wondering how i can determine if ive already processed/read the contents of a cd before.... im assuming that each cd will have some sort of unique serial or identification number.... if it has, what classes/mentod do i have that i can extract this info....thanks for any help you can ...

array of tcp connections

361 byte By h2opologirly69a at 2007-11-27 8:01:28
hello everyone,I want to creat an array of servers to connect to (configurable hots:port) and send a command to be invoked like "something\n"then close the tcp connection? whereis a good place to start reading about this or maybe a snip of code or two like the array part at least, I would be ...

Passing Objects from Client to Server (and back again)

1661 byte By haroldclementsa at 2007-11-27 8:01:38
Hello forum, I having trouble with passing objects from client to server and back again.a) I have created a client server relationship where by the client creates an instance of an object (player.class), fills it with some data (setPlayersName(String);) then passes it to the server. The Player ...

Sorting using 2 parameters

532 byte By Lexus316a at 2007-11-27 8:01:54
Hello,I have a collection of objects which need to be sorted based on 2 parameters. One param is priority and the other is time. I need to sort this collection based on priority first. Every priority in turn could have a smaller collection which will be sorted based on time. All I could think ...

Java concurrency tutorial ambiguity

470 byte By Raphael.Blancharda at 2007-11-27 8:02:19
Hi I was reading the tutorial on concurrency at http://java.sun.com/docs/books/tutorial/essential/concurrency/atomic.html and I found a passage that I is unclear to me. The article states that: "Using volatile variables reduces the risk of memory consistency errors". Does it reduce the risk or ...

HTTP Jar Download Read Timeout

280 byte By robert_difalcoa at 2007-11-27 8:04:09
For some reason I've been having a hard time finding the setting which controls the read timeout for JAR downloads. At the moment it looks like it will never timeout such that if I am about to download a jar and the server goes down, the read will never timeout.TIA

Scope of Threads

1258 byte By AsSiDuL0Usa at 2007-11-27 8:04:14
Does anyone know. I want to have users be able to enter commands into a text field, and then have the text field action listener create a new thread to handle the command (because some commands are really long). My question is, after I start the newly created thread, and then return from the ...

ObjectOutputStream.writeObjectOverride

2505 byte By CodeMonkey9358a at 2007-11-27 8:04:29
(Please don't laugh. I know the answer is obvious, but I just can't see it. Be gentle).Can anyone explain why this doesn't work? I'm trying to extend ObjectOutputStream's writeObject class so I can watch classes as I serialize them. However, I can't seem to get my class to override the ...

BufferedReader problem with intermittant Socket reads and writes

2291 byte By GTSchemera at 2007-11-27 8:05:11
I've tried searching around (and found useful information in these forums) but I can't seem to find anything on this exact problem...hopefully someone can give me a simple pointer in the right direction.I'm trying to write a networked game, where a single server has multiple clients ...

Best Way to Handle IOException in ServerSocket

92 byte By GideonRaya at 2007-11-27 8:05:51
What is the best way to handle IOException thrown by ServerSocket's accept() method?

Sprting a HashSet by propert

212 byte By S1lv3ra at 2007-11-27 8:06:00
Hi all,I want to sort a Set by a property that is in the objects of the set. The property is a String. I searched around the net but could find anything that would relate to my problem.Greets

Mapping between Java Threads <-> OS Thread

433 byte By chaos_begins_herea at 2007-11-27 8:06:30
Hi,I have some assumption, I just need to make sure whether they are valid.1. When a thread in created in Java, a native thread will also be created in OS. Java Thread mapped to os thread. So if create 10 threads in java, I expect my task manager to show so many threads for that particular ...

Session doesnt expire even after the browser is closed.

524 byte By rahul.aggarwala at 2007-11-27 8:07:09
Hi All,I have facing this issue for quite some time now. 1. I login into my application using Firefox. User now can view below the line pages.2. Open another window of firefox.3. Close the window open in the first step.4. Hit the application URL in the second firefox window and u find the user ...

HTML form fill

491 byte By seabhcana at 2007-11-27 8:07:44
This is really a combined Java/HTML question;I have a Java app I'm writing and it will require a license. To request a license, the java opens a particular website where the user will fill in some html forms and click "submit". So far, no problems.But, there is a long license request key, and ...

how to render an image in browser from server to client

289 byte By seethasrinatha at 2007-11-27 8:07:48
I can able to upload an image in a repository and i can able to display the image on my local machine ,but i cant able to render from server (i used <img> tag in jsp) ,and i also tried thru buffer outputstream();i badly need help from yousrinath@incubatesoft.com

Netbeans RMI

431 byte By divinea at 2007-11-27 8:07:54
Hi It may be very stupid question, but i am not able to run my RMI applicayion on netbeansI have implemented all the things -defined the remote interface- my class is Hello.javaimplemented the interface - impHello.javacreated the server class- Helloserver.javacreated the client class- ...

Collection to Multiple Collections

735 byte By S1lv3ra at 2007-11-27 8:08:15
I have a collection with elements of the type "Abonnement" with a property called "bedrijf" of the type Bedrijf.Now i want to generate Objectswith 1 property and a Collectione.g.public class NewObject{private Bedrijf bedrijf;private List<Abonnement> abonnementen;//and getters /setters for ...

howto connect to a .net webservice from Java

749 byte By jacob_hansena at 2007-11-27 8:09:50
HiThis is kind of a noob question, but i hope then its easy to answer:-)I need to make a Java Webservice Client capable of calling a .net webservice created with WSE3.0.The webservice is using the ws-security 1.0 defined in the OASIS specification.I have been searching these forums for any post ...

Do TCP/IP and UDP not mix?

700 byte By RedUnderTheBeda at 2007-11-27 8:09:52
I'm trying to write a game that uses UDP networking, but for some messages I wanted to use TCP/IP to make sure they got there. So I had a datagram socket on one port and a tcpip socket on another port. This yeilded pretty poor results. 30% of the time the game would run fine, 50% of the time ...

jconsole connection trouble. Port redirection?

13983 byte By _lauria at 2007-11-27 8:09:56
Hello!I have a strange issue with jconsole and my JMX enabled daemon. It used to work fine until sysadmin in datacenter placed out machine behind a kind of firewall (cisco accesslist or something like that).After that remote connection between jconsole and server no longer can be ...

Problem reading string from client

7673 byte By Mjacobsa at 2007-11-27 8:10:27
I am having trouble sending the filename before i send the file and storing it to a string on the server. I always stores some gibberish string. Can someone please helpServer codeimport java.io.IOException;import java.net.ServerSocket; public class Server {/** * @param args * @throws ...

object creation

736 byte By vAaka at 2007-11-27 8:10:37
Hi,I hope I'm in the right topic for this...I have been looking into object creation a little bit and although I get the whole idea of loading-linking-initialization etc, I have a little problem with the Class-object or field that is created in each class that is loaded into the JVM.I read ...

How to send a data from JSP to a lot of Swing clients?

293 byte By Chavdar_Chernashkia at 2007-11-27 8:11:11
Hello,Can you recommend me how to do this?My idea is to run inside the APP server a Socket server, which i want to be started on APP server startup.Should i use MBean for that or there is any better way?Thank you for any hints and Kind regards,Chavdar

Identifying server timeout on a Socket

702 byte By AsSiDuL0Usa at 2007-11-27 8:12:01
I am using a Socket to connect to an ftp server that automatically times out the connection after 3 minutes of inactivity. I have tried to set up conditionals to determine if the server has timed out the connection before I send a ftp command but none of them work. After the server has timed me ...

capture echoed text from shell script

176 byte By PatrickFinnigana at 2007-11-27 8:12:09
I have a korn shell script that echoes a word to the terminal. From within my java application, is there any way to call this script and capture the text that it echoes?

ClassNotFoundException when deserialized from web app

3429 byte By jtigrea at 2007-11-27 8:13:11
Hi,Sorry for being little over descriptive here. I have an issue deserializing a file that contains a Map<String, List><POJOs>>. These POJO bean classes are stored in a jar file uder web-app/lib. I can deserialize the file from a standalone java program, from tomcat web app when ...

Whare is BlockDataException class?

453 byte By SachinChitalea at 2007-11-27 8:13:12
I am almost sure that I am making some mistake. But can someone please point out where to find BlockDataException class?I am asking this because:Serialization spec @ http://java.sun.com/j2se/1.5.0/docs/guide/serialization/spec/input.html#5903 says that:2. If a block data record occurs in the ...

Preventing Server Timeout on a Socket

765 byte By AsSiDuL0Usa at 2007-11-27 8:13:15
I have been questioning my solution to preventing server timeout and was wondering if anyone knows of a better way to do it. I am using a socket to connect to a ftp server which times out the connection after 3 minutes of inactivity. I have tried using the setKeepAlive(true) method for the ...

help? --null pointer thrown when add element to synchronized LinkedList

5692 byte By hackmagica at 2007-11-27 8:13:17
Hi all,i am messing about writing a network game and have two linked lists synchronized using the Collections.synchronizedList() method to return a synchronized List.i am accessing the Lists concurrently from 2 threads started using the following excerpts:class ServerUI{...serverGameHost=new ...

Write blocked waiting on read

8941 byte By MarkVa at 2007-11-27 8:13:39
Hi all,I have been experiencing difficulties with simultaneous read/write with AsyncIO. For my scenario that the client/server application is being developed, a client may send requests or status information at any given time. Hence continual monitoring on the incoming stream is required.The ...

how to send sms from java code

173 byte By portal_javaa at 2007-11-27 8:13:47
hi I have involved in a project where I need to send sms to mobile from java code.Can anyone help me.if u have code please send me.thanks dhinesh

how to send message from computer to remote user

603 byte By mohan_dossa at 2007-11-27 8:13:52
hi, i want to know ,how to send message from my PC to remote user when some successful event occurs.I think and i am not sure that these are possible ways:1.using sms providers we can send messages by doing contract with them.2.using sms gateways we can send messages through their sites and we ...

[ask] package

149 byte By v-va at 2007-11-27 8:13:54
where i can found this packagesunw.admin.snmp.*;i need JMAPI class where i can find it. any one reply me i beg you please

Lan Messenger...

3066 byte By Aditya-iiitma at 2007-11-27 8:14:24
HiI want to develop a lan messenger using java.I have written a client code to interact with a serverit connects properly but as soon as i start a thread for listeningconnection is ended. please suggest me on this....below i m pasting my code and the error messagecode:import java.awt.*;import ...

Synchronization Static and Non Static Methods

213 byte By Sudharsana at 2007-11-27 8:16:27
Hi I am confused about object lock and class lock What is differnce between Synchronized static method and Synchronized nonStatic method .Please explain me with one exampleThanks

Exception in thread "Thread-2" java.lang.NullPointerException

6000 byte By Aditya-iiitma at 2007-11-27 8:18:45
HiI want to develop a lan messenger using java.I have written a client code to interact with a serverit connects properly but as soon as i start a thread for listeningconnection is ended. please suggest me on this....below i m pasting my code and the error messageimport java.awt.*;import ...

file transfer with DataInputStream / DataOutputStream

3771 byte By fed3xa at 2007-11-27 8:18:54
hi there! I'm implementing a protocol that allows transfer a number of files over a socket TCP.Files can be .jar, .class or .java . in the first two cases I must send it as binary data, in the last case, as text .The protocol is pretty simple, the sender first sends a String that represent the ...

How to make a server accept more clients after terminating the first

4023 byte By hogla at 2007-11-27 8:19:21
Hi, I'm having a problem with my program. It is a server program that can handle one user at a time, but after closing the client, the server just hangs.. It still takes connections, but it doesn't respond to telnet commands after the first client has disconnected. How do I go about changing ...

File Not Found after soket transfer

6571 byte By Mjacobsa at 2007-11-27 8:19:56
I have code written to upload a file to the server. the file uploads fine when i dont specify the dir. It uploads to the server current dir, but when i try to upload it to directory "tmp/uniqueDir/filename" that i create in my code i get filnotfound exception. can someone please help me figure ...

File not found after socket transfer

6571 byte By Mjacobsa at 2007-11-27 8:19:57
I have code written to upload a file to the server. the file uploads fine when i dont specify the dir. It uploads to the server current dir, but when i try to upload it to directory "tmp/uniqueDir/filename" that i create in my code i get filnotfound exception. can someone please help me figure ...

StremCorrupted Exception reading on an object

8160 byte By rajitoora at 2007-11-27 8:20:02
hi guys i m getting StreamCorruptedException just don't know why. its a simple program. below is my main class.package Basics1;import java.util.*;import java.io.*;public class UseStaticIpData {public UseStaticIpData() {}public static void main(String[] args)throws IOException{StaticIpData sipd ...

Overriding final for assignment?

387 byte By _dnoyeBa at 2007-11-27 8:20:09
I have a class member that has been final for a long time. I decided to implement the clone method. This requires me to reassign this final variable. But this is the only time this would be reassigned.It seems the copying and serializing requires special behaviors often. I am wondering if there ...

Interrupt BufferedInputStream.read()

314 byte By James_Shepparda at 2007-11-27 8:20:15
I have a BufferedInputStream (using System.in as its underlying InputStream), that is blocking on a read() operation. At some point, I need to signal the thread that it is a part of to stop executing. However, if no more user input ever comes, then it will just sit there forever. How can I get ...

java.lang.UnsupportedOperationException

648 byte By AbHaYkUmARa at 2007-11-27 8:20:36
Getting Exception in thread "main" java.lang.UnsupportedOperationExceptionat java.util.AbstractCollection.add(Unknown Source)at test2.test2.main(test2.java:31)when executing Map map = new HashMap();map.put(new Integer(1),"abhay");map.put(new Integer(2),"kumar");Set set = ...