java

SSL and SocketChannel

Ideally, I only need a simple SSLSocketChannel: I already have a component that reads and writes message over ordinary SocketChannel, but for some of those connection, I have to use SSL over the wire; the operations over that connections, however, are the same. Does anyone knows a free SSLSocketChannel implementation (with the appropria...

how to send data to client using nio

Is there any simple example for reading data from server and sending the response to client using java NIO socket channel Thanks, Deepak ...

Line numbers in StackTrace point to method start

We're developing a web application with Rational Application Developer 7.5 (based on Eclipse 3.4) for WebSphere Application Server 6.1 . When examining stacktraces on a staging server, the line numbers always point to the beginning of the methods, never to the actual line. In the local development environment (each developer has his loca...

Loading a keystore without checking its integrity

This question is in the specific context of the Java class java.security.KeyStore and its load(InputStream stream, char[] password) method which can accept null values for password to bypass integrity checking. What are the risks involved with loading and querying a keystore without checking its integrity? The keystore will be queried ...

why can not the value of primitive type variable be changed?

public class testtype { private int a; private double b; testtype(int a,double b) { this.a=a; this.b=b; } public void maketoequal(testtype oo) { oo.a=this.a; oo.b=this.b; } void trytoequal(int c) { c=this.a; } public static void main(String[] args) { testtype t1,t2; t1=new ...

How do you debug Java Applets ?

Currently, the only information I have is a one-line error message in the browser's status-bar. Do you know how I could get a stack-trace for example ? ...

i have to devlop a web-app using grails + workflow + java what is best way to integrate them ? is there a tutorial ?

i have to devlop a web-app using grails + workflow + java what is best way to integrate them ? is there a tutorial ? ...

Is there any way to determine if an object in Java is softly reachable?

In order to perform some testing, I'd like to check how my application behaves when some or all of the objects I have stored in a cache of SoftReference'd objects are disposed of. In order to do this, I'd like to manually clear the references stored in the cached SoftReference objects - simulating the VM disposing of those objects - but...

Is there a template or something for generating a switch statement for Java enum in Eclipse?

Is there a template or something for generating a switch statement for Java enum in Eclipse? So that when I got an enum and I want to have a switch with all the values, I didn't have to write all it myself? ...

Argument checking or Design-by-Contract in java (GWT). Where to start?

I am playing GWT. I am looking for basic argument checking. I do not require invariants or result ensures. What I am interested about it best practises on the topic. For example, in c# I use one of this options: if (arg1 != null) throw new ArgumentNulException....; // Official for public API; Args.NotNull(arg1); // Home grown. Contr...

Where does a career as Java Corporate Trainer lead to?

I have joined a private company as a Corporate Trainer on Java technologies. My job is to teach java to programmers. I am 25, having a degree in computer applications. I am handling only core java,servlets and jsp batches as I am not experienced in JEE frameworks like Spring, Struts. Ajax, JSF ,Hibernate etc. I want to know how I ca...

What can I use to create a REST client in Java?

If I want to use Java to create a REST client, what should I use? Can i use CXF? ...

Desinging an Application for xmodem Transfer Through Dial-up in Java

I want to desing an application to send/receive a file with xmodem (written in java, I found the source code at http://stackoverflow.com/questions/606074/implementation-of-x-modem-protocol-in-java). I've decided to modify this code. First I should dial a number on the client-side and listen on the server-side. My problem is that I don't ...

How to avoid that pressing the ALT key takes away the focus from my GUI.

I'm developing a java app with swing in Windows. The problem is: after pressing (and releasing) the ALT key, the next key press has no effect (there won't be a keyPressed event fired). Only the releasing the next key will be recognized. Pressing and releasing CTRL or SHIFT after ALT has no effect at all. The you first have to press anot...

UnsatisifiedLinkError with ojdbc14.jar

Hi guys, I am trying to run some JUnit tests that connect to an Oracle database and whether a connection attempt is made. The following error is thrown: oracle/jdbc/driver/T2CConnection.t2cGetCharSet([CI[CI[CII[SLoracle/jdbc/driver/GetCharSetError;)S at oracle.jdbc.driver.T2CConnection.getCharSetIds(T2CConnection.java:2801) at oracle....

Multi-line tooltips in Java?

I'm trying to display tooltips in Java which may or may not be paragraph-length. How can I word-wrap long tooltips? ...

BadPaddingException: pad block corrupted

I am trying to decrypt a file in Java which was encrypted in C# using Rijndael/CBC/PKCS7. I keep getting the following exception: javax.crypto.BadPaddingException: pad block corrupted at org.bouncycastle.jce.provider.JCEBlockCipher.engineDoFinal(Unknown Source) at javax.crypto.Cipher.doFinal(DashoA13*..) at AESFileDecrypter....

How does SocketChannel know when reading a file is completed?

I am using socket channel and NIO concept to read data from client. How does Socket Channel knows when reading a file is completed? ByteBuffer byteBuffer = ByteBuffer.allocate(BUFSIZE); int nbytes = socketChannel.getChannel().read(byteBuffer); I am reading the data all at once if the data is small, but if the data is large, I read the...

How to keep whitespace before document element when parsing with Java?

In my application, I alter some part of XML files, which begin like this: <?xml version="1.0" encoding="UTF-8"?> <!-- $Id: version control yadda-yadda $ --> <myElement> ... Note the blank line before <myElement>. After loading, altering and saving, the result is far from pleasing: <?xml version="1.0" encoding="UTF-8"?> <!-- $Id: ver...

How do I copy an object in Java?

Consider the below code: DummyBean dum = new DummyBean(); dum.setDummy("foo"); System.out.println(dum.getDummy()); // prints 'foo' DummyBean dumtwo = dum; System.out.println(dumtwo.getDummy()); // prints 'foo' dum.setDummy("bar"); System.out.println(dumtwo.getDummy()); // prints 'bar' but it should print 'foo' So, I want to copy the...