java

Are there any x.25 protocol Java libraries ?

I need to communicate with another machine using the x.25 protocol and Java. Are there any Java Libraries available which will help me to accomplish my goal and is it even possible doing it with Java ? ...

With Hibernate, can I mix table-per-subclass and a <map> within the same table?

I'm attempting to map an object model for "Promotions"; i.e., a customer enters a promo code during signup. Different promo codes might have different types of "benefits", meaning what we are giving to the customer. For example: promo code XYZ123 will give the customer free minutes in his or her account, while a different promo code w...

I created a PrintWriter with autoflush on; why isn't it autoflushing?

My client is a web browser, and sending request to myserver using this url: http://localhost This is the server side code. The problem lies in the run method of the ServingThread class. class ServingThread implements Runnable{ private Socket socket ; public ServingThread(Socket socket){ this.socket = socket ; System....

Hibernate one to many using something other than a primary key

I have a class A that has a set of B's. However, these two objects are linked by fields that are NOT the primary key. For B, I can use , but how do I specify that the join should be in A.secondary_column, Not A. table_primary_key_id ? <class table="a"> < id column="table_primary_key_id" > < /id> <property column="secondary...

Java HttpConnection refused, but curl equivalent works

I'm losing my mind on this one. My curl command works: curl http://testuser:testpwd@qabox3:8501/xmlcontroller But, when I try what looks like an equivalent http connection in Java it gives "connection refused". What am I missing? I've tried a dozen flavors of trying to make this connection today and am out of ideas. URL url = ...

Java Data Types: String and Array

Hello, I've been going through Sun Microsystem's Java Tutorial and got some questions while reading the following: I/O from the Command Line: The Console Object "Second, readPassword returns a character array, not a String, so the password can be overwritten, removing it from memory as soon as it is no longer needed." My questions ar...

Inside clipping with Java Graphics

I need to draw a line using java.awt.Graphis, but only the portion of the line that lies outside a rectangle should be rendered. Is it possible to use the Graphics clipping support? Or do I need to calculate the intersection and clip the line myself? ...

Casting to a Comparable, then Comparing

I'm really trying to like generics, but so far the trouble they've caused outweighs any benefits. Please, please show me I'm wrong. I understand the necessity of adding @SuppressWarnings("unchecked") when using generic-free frameworks (Spring, Hibernate). This alone really reduces generics' value, as does requiring classes be passed i...

How to Properly Escape Triply Nested Quotes in JSP

We just upgraded Tomcat and the newer Tomcat doesn't like nested quotes in the tag, so we have to alternate between single and double quotes. For example, We used to have, <form id="search" action="<fmt:message key="search.url"/>"> Now we can change it to, <form id="search" action="<fmt:message key='search.url'/>"> What should I d...

Multiple threads in Java causing problems.

Sorry for another vague example...but I have a single class where I'm starting a new thread instance. However, if I add a new thread instance, it interrupts (destroys?) the first. But, if I run two instances of the class (separately, after I turn them into jar files) where each instance only opens up a single thread, they both run concu...

Java: Collection RemoveAll Ignoring Case?

Ok so here is my issue. I have to HashSet's, I use the Removeall method to delete values that exist in one set from the other. Prior to calling the method, I obviously add the values to the Sets. I call .toUpperCase() on each String before adding because the values are of different cases in both lists. There is no rhyme or reason to th...

JAVA element.getElementsByTagName Restrict to Top Level

I have an XML file as follows: <rootNode> <link>http://rootlink/&lt;/link&gt; <image> <link>http://imagelink/&lt;/link&gt; <title>This is the title</title> </image> </rootNode> The XML Java code using DOM is as follows: NodeList rootNodeList = element.getElementsByTagName("link"); This will give me all o...

How do you serialize an Exception subclass in JAXB?

How do you serialize a subclass of Exception? Here is my exception: @XmlType public static class ValidationFault extends Exception { public ValidationFault() { } } I have tried all sorts of variations on using @XmlTransient and @XmlAccessorType, but JAXB continually tries to serialize the getStackTrace/setStackTrace pair, which ...

Algorithm to generate Poisson and binomial random numbers?

i've been looking around, but i'm not sure how to do it. i've found this page which, in the last paragraph, says: A simple generator for random numbers taken from a Poisson distribution is obtained using this simple recipe: if x1, x2, ... is a sequence of random numbers with uniform distribution between zero and one, k is the first int...

Java: How do I ignore certain elements when comparing XML?

I have an XML message like so: <root> <elementA>something</elementA> <elementB>something else</elementB> <elementC>yet another thing</elementC> </root> I want to compare a message of this type produced by a method under test to an expected message, but I don't care about elementA. So, I'd like the above message to be considered...

Is there a standard way to handle many different options for mouse events in java?

Hi all. I'm developing a grid based sim game in java, and I was wondering if there is a standard way of doing the following. I have a panel which is the game panel, and there are many different things which could happen when the panel is clicked. For example, when building a room, there are several stages, where dragging the mouse and l...

Swing's BasicHTML.createHTMLView metrics usage

I'm doing some graphics processing and HTML is a perfect choice for styling the displayed content. I'm trying to reuse swing's built in html support, and it works perfectly if I hard code the height passed to View.paint, but I can't figure out how to determine how tall the bounds of the rendered content would be at runtime given a specif...

Java: Why method type in .class file contains return type, not only signature?

Hello, There is a "NameAndType" structure in the constants pool in .class file. It is used for dynamic binding. All methods that class can "export" described as "signature + return type". Like "getVector()Ljava/util/Vector;" That breakes my code when return type of the method in some .jar is changed, even if new type is narrower. ...

Not enough Storage is available to process this command when running java utilities from command line

I'm on Windows Vista 64 bit, with a 64 bit jvm installed. I'm trying to use jstack and jmap -- two utilities that come with the JDK -- to peek into an application server's guts. This works fine on a windows xp machine, 32 bit. However, when I run these commands against the processid for a ColdFusion application server on this vista64 ma...

Is it possible to use Java to retrieve assembly version(DLL)?

Hello, I recently pickup Java so I have very limited knowledge, but I would like to know if it's possible to get DLL version using Java. If it is not possible, is it possible to use C# to get Jar version through the manifest file? ...