Java-index »» Core »

Using threads and collecting responses

621 byte By faliscoa at 2007-11-27 9:52:24
Hello, I am doing multiple requests to diferent web services from diferent providers. I want to do the requests simultaneously and I think the best way is using threads. I am thinking to create a main class that creates a thread instance for every request (max 5) and then wait for the responses ...

Can java use proxy to connect internet?

103 byte By youhaodiyia at 2007-11-27 9:52:31
My program works in an intranet environment. Can I add proxy into my program to access internet?

Concurrency issue

527 byte By VishVa at 2007-11-27 9:52:35
Hi,I am working on J2EE application and using Hibernate.Application is online submission form which contains questions. User has to respond to each question. when user fills the response and click on save. Responses will be stored into response table. Now i am having problem with one user's ...

Sending content in an html page via email as body

537 byte By Shigaa at 2007-11-27 9:53:15
HiI am really in need of a prompt help for sending a web page which contains some html content as an email body.I really have no clue about this.I have tried searching in google but could not find any thing in java.I have everything ready for sending an email, i.e. to, from and subject.The only ...

RMI + SSL need help

5623 byte By lukaTNa at 2007-11-27 9:53:37
Hi,i want create a simple RMI program with SSL sockets but when i run the client i've this type of error:javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failureat sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:184)at ...

Garbage when Compressing a Byte array

2067 byte By Kurdta at 2007-11-27 9:53:47
Hi all guysI am sure you can help me with this, I am using jazzlib ( http://jazzlib.sourceforge.net/) ZIP library for deflating and inflating data, I was all day trying to find examples and I came with this:public byte[] compress(byte[] input) throws IOException{Deflater compressor = new ...

I can't seem to find a function to check to see if a connection was success

7802 byte By lokiea at 2007-11-27 9:54:30
Hello everyone. I'm running into 2 problems that I can't seem to find functions for after reading the java API on socket and serverSocket.If a client closed a connection on my server, like if someone telnets into my server, then closes the console, i get the following:Event from: ...

RMI Works In One Direction, But Not When Config Flipped

955 byte By EJavaM07a at 2007-11-27 9:54:40
Hi All,Interesting problem: I have an SSL-RMI server, running either as an application, or as a service using JS Wrapper, on PC-A, correctly serving content to a client running on PC-B. But when I flip the configuration, such that PC-B is now hosting an SSL-RMI server, PC-A's client is ...

Corrupt File after file transfer

2431 byte By Mjacobsa at 2007-11-27 9:55:03
I have written code to transfer two files from the client to the server. Every time I transfer the file and try to decompress it using gzip, it says "corrupt input. Use zcat to recover some data." Is there any way I can fix this? Please help...Client side:for (int z = 0; z < files.length; ...

Corrupt Files After File Transfer

2423 byte By Mjacobsa at 2007-11-27 9:55:04
I have written code to transfer two files from the client to the server. Every time I transfer the file and try to decompress it using gzip, it says "corrupt input. Use zcat to recover some data." Is there any way I can fix this? Please help...Client side:for (int z = 0; z < files.length; ...

Resorting the entries after one changes

1370 byte By _dnoyeBa at 2007-11-27 9:56:05
After some usage of my program I realized that my TreeSet is giving me problems. Its a sorted set with compareTo based on name. When the name of an entry changes I need to resort the set.I know its bad for any equals or compareTo to change after the item was put into the set. So I figured I ...

<E extends Exception> Only Compiles Sometimes (possible bug)

1930 byte By DejasPerPera at 2007-11-27 9:56:16
Consider:public interface RootedNodeAlgo<R,T,J,E extends Exception> { public R forParentNode(RootedNode<J> n, T... input) throws E; public R forLeafNode(RootedNode<J> n, T... input) throws E;}public abstract class LeafSyntaxNodeBase extends SyntaxNodeBase implements ...

Remote Desktop in RMI

189 byte By gopi.sun.coma at 2007-11-27 9:56:49
hi if any one having the coding to connect remote machine using RMI...it is possible to do it in JAVA ?because i need application like GoToMyPc...pls help

ReadLine problem

978 byte By jahanuma at 2007-11-27 9:57:28
Hi guys, I have a slight problem here. My code is simple and is as follows:import java.io.*;public class Average {public static void main(String[] args) throws IOException {double numbers = 0.0;System.out.println("Please enter 5 numbers");BufferedReader br = new BufferedReader(new ...

pinging a host

236 byte By Vive_JavaNETa at 2007-11-27 9:57:32
Hello, can anyone help me out with how to ping a host using java I dont have to use Process p=Runtime.getRuntime().exec("ping ........instead I need some powerful mechanism.. i am working on java 2 sdk 1.5.Thank you

UPD framework

245 byte By nichelea at 2007-11-27 9:57:34
Hi All,I'm looking for a good java framework that can help me with a UDP multicast application. Something like JGroup (that indeed is more that what I need) but with Apache license.Is there anything ?ThanksSte

Problem with binding when classpath contains space

434 byte By Andrei_Marchankaa at 2007-11-27 9:57:41
Hi everyone,My application has space in the path and as a result space appears in the classpath. So rmi won't work and I'm always getting MalformedURLException. Also I won't be able to change classloader for distributed object, because I don't create it directly. I use Avalon framework.If i ...

Stream Closed Error

9435 byte By domnul_mihneaa at 2007-11-27 9:58:00
Hello!I have this 2-class package which gets informations on Microsoft SQL Server 2005 tables and table content. It worked perfectly on J2SE 5. Today I moved to Java J2SE1.6 u1 and recompiled the project. Now, it triggers bizzare Steam Closed exceptions when trying to read a line from the ...

Problem with using generic methods

2456 byte By mr.hwortha at 2007-11-27 9:58:33
Hello. I'm having a bit of trouble figuring out how to correctly parameterize a function. Here is some sample code to show what I'm trying to do.interface SampleInterface<T> {}//Emulating a set of SampleInterfaceinterface OtherSampleInterface<T extends ...

java.rmi.ConnectException: Connection refused to host:

2160 byte By Sopha at 2007-11-27 9:58:50
HI,I have both RMI client and server in my machine.i started the server successfully withC:\Documents and Settings\benedict\workspace\RMIDemo\bin>java -cp C:/"Documents and settings"/benedict/workspace/RMIDemo/src;./;c:/"Documents and settings"/benedict/workspace/RMIDemo/bin/compute.jar ...

methods accessiblity restrictions

2287 byte By emeraldcpa at 2007-11-27 9:59:08
I am confused about some examples from Angelica Langer FAQ regarding method accessiblity.class Box<T> {private T t;...public int compareTo(Comparable<? super T> other) { return other.compareTo(t); }public Box<? super T> copy(){ return new Box<T>(t); } }public void ...

Callable interface

1882 byte By emeraldcpa at 2007-11-27 9:59:09
I am leaning concurrency programming in jdk 5, and ran into trouble with Executor framework, actually, it's a generic type problem.I want to use Executor.invokeAll to execute a collection of tasks, the signature of this method is:<T> List<Future><T>> ...

cuncurrency issue using ArrayList

716 byte By mullapudia at 2007-11-27 10:00:07
Hi allI have an arrayList object, 10 threads are populating data in to that arrayList object, another main thread will fetch data from that object. I am using iterator object to run the while loop with hasNext() method to fetch data in that main thread. but if that main thread runs before the ...

Are Local Object references thread safe?

4682 byte By mrutyunjaya at 2007-11-27 10:00:51
Hi All,I have a static method which has lots of local objects which are basically references to nodes of an static DOM object which had been created at the application startup time.. I want to know if multiple threads access that static method,will the local objects inside the method be thread ...

once I send 1 string, the rest are cut off, any ideas?

6222 byte By lokiea at 2007-11-27 10:01:01
Hello everyone.For some reason when I send my first string through the socket, everything works fine. But after that Its cutting off the first 2 or 3 characters of the string and I have no idea why because I'm flushing the output buffer before and after I send the the string to the output ...

JAVA Servr Soket problem...PLZ Help ME

1006 byte By jobina at 2007-11-27 10:01:48
HIi have a server port whch can support mulptiple connection. im running this as a Java HotSpotserver .im getting problm after some, im running this server on 5001 port ,it will accept many connection and running propel. the clients are applets.these are the problems i am getting1..From the new ...

Problem while using controls with MS ActiveDirectory

1457 byte By Roshitha at 2007-11-27 10:02:16
Hi ,I am facing a strange problem while using controls with Active Directory. I am using a SearchControl to set the total number of users to be returned matching the filter to 800 , and used the PagedResultControl to set the page size as 400 . Here is the the sample code i usedSearchControls ...

Help reg. serialization compatibility

977 byte By Anand.Ramana at 2007-11-27 10:02:18
Hi,We developed a web-application using J2SE 5.0. It runs in IBM Websphere 6.1(with IBM JRE 5.0). We have an applet for rendering our reports. The applet communicates with the web-application to obtain serialized form of the data that needs to be rendered in the applet. The browser in the ...

JMX and JDK 1.4

239 byte By OGBa at 2007-11-27 10:02:25
Am I able to use JMX in my application that builds on JDK 1.4? Porting it to 1.5 or later is not really an option at this time. Downloading a couple of JAR files and packing them with my application is not a problem if that helps...

Dynamic vs Model MBeans

273 byte By OGBa at 2007-11-27 10:02:58
I'm having trouble understanding what features and advantages Model MBeans are offering compared to Dynamic MBeans? I would appreciate any examples of use.Also, there aren't any problems with combining several types of MBeans in the same application, right?

how to stop thread A from thread B using a button

511 byte By xpantaa at 2007-11-27 10:03:28
Hi,I have created a thread A which in turn creates a thread B. Is it possible to press a button on thread B that stops execution of thread A (and consequently thread B, of course)?More specifically, thread A is a client thread that waits for server data. If it takes too long I would like to ...

Accesing The Host through Telnet (Port NO:23) Usng Java Code In Linux OS

624 byte By BangloreGuya at 2007-11-27 10:03:47
Hello To All,I wrote the telnet (Port No :23) Program inorder to the access the Linux Host.After Giving Login and Password through Code.I am trying to fetch the data from there.I am doing it through the OutputReader and BufferedReader Class and I have written Try and Catch Block also.In My File ...

Reflection Sample - Whats wrong in this?

901 byte By JayKay007a at 2007-11-27 10:04:00
Please find the below code.public class FiledRef {public static void main(String[] args) {try{Class clas = null;clas = Class.forName("fieldRef.TwoString");System.out.println("VALUE IS -> "+incrementField("val02",clas));}catch(Exception ex){ex.printStackTrace();}}public static int ...

Difference between different Context classes

306 byte By 4tha at 2007-11-27 10:05:00
Adler_Steven always used this:// Create the initial directory contextLdapContext ctx = new InitialLdapContext(env,null);I use this:DirContext ctx = new InitialDirContext(env);both methods work for changing a password...Can someone explain that to me ...

writing Java Objects to a file

506 byte By munnadeea at 2007-11-27 10:05:10
Hi,I had been using files and Java IO API for a time but in my new implementation I want to write few Java objects in to a file and fetch them as "same objects" in to a datastructure (such as an array or map) when I start my application again. I was wondering if there is any mechanism that I ...

logged in windows username cant be searched in LDAP tree on Windows 2000 AD

1895 byte By 4tha at 2007-11-27 10:06:12
That is my active directory of my TEST Windows 2000 server: http://img248.imageshack.us/img248/918/adwn6.gifOn the image yu will find 4 schools with shortcut names called:OU=ASROU=EDSOU=EKS (EK school for example)OU=THS (TH school for example)Under every OU="shortcut of schoolname" you will find ...

Two - Thread Program

538 byte By sanlearnsa at 2007-11-27 10:06:17
Hi All,I want to write a pgm using Threads given the problem scenario as:I'm pretty new to Threads!Write a NumberFactory class - AddNumber and DisplayNumber are the threads running in the class - AddNumber will add all ten numbers continuously - DisplayNumber will display numbers in reverse ...

Problem with RowSetDynaClass

1079 byte By dhaval_shaha at 2007-11-27 10:06:52
I'm using the RowSetDynaClass as I need to close my resultset and return the connection to the connection pool quickly. Resultset rs = stmt.executeQuery("something");RowSetDynaClass rowset = new RowSetDynaClass(rs);I iterate through it by the following:Iterator iter = ...

InetAddress.getLocalHost().getHostAddress() returns loopback on server?

390 byte By CrystalDragona at 2007-11-27 10:08:02
I'm trying to create a script to test server availability. In the response I would like to return the IP of the server. The following works fine locally but when I run it online it just gives me the loopback address.InetAddress.getLocalHost().getHostAddress();Granted the server is a shared box ...

Which collection to choose?

805 byte By Fastfoxa at 2007-11-27 10:08:20
I'm unsure of what collection to use in my program. These are my desired characteristics:- synchronized (I guess all of them can be);- easy addition/removal the beginning and end- easy merging of two collection objects;- sorted;- fast scrolling at any place.The idea is to store data received ...

simple string sending question

10147 byte By marco_wua at 2007-11-27 10:09:48
Dear all, I am writing a simple program which is a simple IM. It will send string and receive string. That means it is a server and a client. I have 4 classes, one is client, one is server, one is GUI, the last one is just call all of them. I think I make something wrong in the Server and/or ...

Multi-Dimensional Hashtable

356 byte By leatropa at 2007-11-27 10:10:21
Does anyone know any fast way to implement hashtableWith SET access as table["key1"]["key2"]["key3"]=vAnd GET access (with "wild cards") like: v = table["key1"][null]["key2"];I can do through simple loop to handle wild card, but that table may have millions of values stored - it will take ...

Building a server application that uses long lived connections

2383 byte By MBuetowa at 2007-11-27 10:10:38
Hello All,Was looking for some advice on this scenario:Most of the information that I have found regarding servers seem to revolve around using disconnected sessions (connections?). An example being a web server type of application ( or a web service for that matter ) where users would initially ...

A question about file lock

992 byte By youhaodiyia at 2007-11-27 10:10:51
In a situation that one program grab a read lock on a file and another program want to write to the file. How does the first program prevent the second program from modifying the file? According to Java API doc, a shared lock prevents other concurrently-running programs from acquiring an ...

Calendar Framework

834 byte By spatnaik77@gmail.coma at 2007-11-27 10:10:53
Hi All,I am working on a project where i have to build a framework for calculating next working days based on predefined holidays, weekends etc.For example :Assume today is July 11 and is friday.I need to calculate the next working day assuming that saturday, sunday are holidays.so my ected result ...

Having issues finding out how many bytes are sent/recieved from a socket.

10870 byte By lokiea at 2007-11-27 10:11:25
Hello everyone.I've searched the forums and also google and it seems I can't find a way to figure out how many bytes are sent from a socket and then how many bytes are read in from a socket.My server program accepts a string (an event) and I parse that string up, gathering the relevant ...

internationalization in java:

446 byte By gautam0001a at 2007-11-27 10:11:33
We need to have traditional character support(chinese, japanese etc) for our applications. The traditional text is available in the oracle database and is displayed correctly in toad but when we access it thru browser/stand alone java app, it is not shown. The language pack is installed correcly on ...

what and all serialized

223 byte By Java_Aspiranta at 2007-11-27 10:11:51
<p>Hi guys,</p><p>I just want to know if i serialize an object, what and all will be serialized, i mean </p><p>apart from variables, whether methods will be serialized?</p><p>Thanks in advance.</p><p>Regards,</p><p>SRI.</p>

After 2nd time running a method my app window freezes 7 seocnds,error msg->

15880 byte By 4tha at 2007-11-27 10:13:21
Hello folks,first you will surely say is that my server is offline or something with the network is wrong but it is not ;-)thats the code:Please read my words after the pasted code at the bottom of the page!import java.awt.Color;import java.awt.Insets;import java.awt.event.ActionEvent;import ...

java.io.StreamCorruptedException: invalid stream header

2755 byte By haroldclementsa at 2007-11-27 10:14:20
I am having a problem with sending two objects (over a socket). I have read in other posts that this could be due to trying to receive incompatible data types but my applications work fine if I send my objects synchronously rather than asynchronously.I will try my best to describe what my problem ...