java

Loading a universal binary with Java

Hi Everyone, I have an Java applet that loads native code through JNI. Everything worked just fine until I made the upgrade to Snow Leopard, and then Safari decided to be dumb. It turns out Safari will only load 64 bit binaries when in 64 bit mode. (You can put it in 32 bit mode, but that is not an option.) I changed my build system (g++...

Should I go 3D for my game? If so, how far and any good tutorials?

Hi all. I have been working on a java simulation game for some time (remaking theme hospital in my own way). Up to now, I have done everything in 2d, using squares and circles etc. I have looked for some tutorials on how to do 3d in java, found coke and code, however I am unsure if this is what i need to use. My idea was either to have s...

Applet HttpUrlConnection Chunked Response problem

I have an Applet with HttpUrlConnection to IIS 6.0 Server. Server response chunked data, but sometimes (some browsers) i have a problem. Server answers stick in certain buffer, and arrive at me when the server close connection by timeout. url = new URL(urlStr); huc = (HttpURLConnection) url.openConnection(); huc.setDefaultUseCaches(fa...

Java Design Pattern

I am trying to design an application where I will have a Map of IAction objects. Each IAction object has a method IAction IAction.processAction() where it is executing the knowledge contained within it. This could querying the database calling a web service, etc. After the execution of each IAction control is then sent to the next IA...

Regex - extract info from a String in Java

Hi all, I have a problem in applying a regex in my Java code. My text string is like this (String myString) name: Abc Def; blah: 1 2 3; second name: Ghi; I need to extract the name information (Abc Def). Name can contain a string of 1+ words. All the properties (name, blah, second name) are spaced with some w...

Is there a helper to know whether a property has been loaded by Hibernate?

I need a helper to know whether a property has been loaded as a way to avoid LazyInitializationException. Is it possible? @Entity public class Parent { @OneToMany private List<Child> childList; } @Entity public class Child { } "select distinct p from Parent p left join fetch p.childList"; // Answer goes here // I want to avo...

Java/C# Kerberos inter-op possible?

Hi there... I have implemented a Kerberos server/client using sockets in Java, where the client sends his service-TGT to the server, and the server knows the client is authentic. My main concern is the snooping 'man-in-the-middle' attack. Someone could capture the TGT, and pretend to be the client. In a pure Java implementation, ...

Listening to all JInternalFrame events - Java

Hi, I'm trying to internationalise a Java applet and with that, support scripts which are written from right to left. I want to set up component orientations for all java components added to the view automatically. My solution so far has to listen to all AWTEvent's using the windows mask: c.getToolkit().addAWTEventListener(listener, A...

HTML page to XHTML with TagSoup

Sorry if this is too simple, but I simply couldn't find a tutorial nor the documentation of the Java version of TagSoup. Basically I want to download an HTML webpage from the internet and turn it into XHTML, contained in a string. How can I do this with TagSoup? Thanks! ...

jruby trim string based on length with ellipses

This is a pretty specific problem, but I'm wondering if anyone would have a brilliant solution. I'm trying to fit a string with a fixed font size in a box of arbitrary size, such that, if the whole string doesn't fit, I want to trim it and ad an ellipses (...). So if my text is "the netherlands" I want to determine what portion of th...

Open-source Java server-side implementations of HTTP auth decoding

I have a requirement to perform HTTP authentication logic within a servlet application, rather than delegating this task to the container. Specifically, I need a way of taking the headers of an HttpServletRequest which contains HTTP auth headers, and having them decoded into a data structure representing the supplied credentials, which ...

how to use a supplied username and password to read a file in Java

I need to read a bunch of binary files from a Java script running on Windows. However, the folder that the files are in has limited permissions. I (i.e. my Windows username) have permissions to read them, but the user that Java runs as (this is part of a web application) does not. If I pass my own username and Windows network password...

Why is Swing Parser's handleText not handling nested tags?

I need to transform some HTML text that has nested tags to decorate 'matches' with a css attribute to highlight it (like firefox search). I can't just do a simple replace (think if user searched for "img" for example), so I'm trying to just do the replace within the body text (not on tag attributes). I have a pretty straightforward HTML...

JRuby limitations when working with Java Classes

As far as I understand JRuby, it is perfectly possible to use Java class inside JRuby code and vice versa, however, I still don't understand few things. can JRuby work with Java Annotations? is it possible to use reflection from JRuby on Java class? is it possible to use reflection from Java on JRuby class? do I have executable classes...

Design pattern for taking user input and invoking method

I need implement a control solution for a computer game I am writing to take user input . I am looking at the Command pattern, but not sure if its a good fit for this. ...

java.util.ConcurrentModificationException on CollectionOfElements

Hi. I seem to get a ConcurrentModificationException when I have a CollectionOfElements inside an Embedabble. If would like to have it like that, however If I change Route from Embedabble's to Entity than everything works fine. I have even tried adding @Version, but that doesn't seem to work. Here are a snippet of my classes. Kart.java:...

How do I switch to another subversion branch in Intellij?

What is the concept of switching branches in IntelliJ? I must be either blind or an idiot... I would assume there'd be a "switch to copy" option or something like that, but there is none... EDIT for clarification: my prev IDE had a simple "switch to copy" option, which updated all files being different from current branch/trunk. Intell...

Subclassing Inner Class from Outer Class versus other Inner Class

I am befuddled why this is allowed public class Foo { class Bar extends Foo { } } Yet this is not allowed public class Foo { class Bar extends Foo { } class Fooey extends Bar { } } The compiler informed that it can not reference Fooey.this before supertype constructor has been called. And this is allowed ...

How to detect signals at the serial COM1 port?

I have a infrared device (both transmitter and receiver). I've connected the receiver to the serial COM port and I send IR signals using the transmitter. I'd like to monitor theese signals and whenever there is no signal, invoke another thread (sms sending code). If I check the signals on hiperterminal, I get some unreadable values. W...

Java: flushing memory out to disk

Let's say I have a Java application which does roughly the following: Initialize (takes a long time because this is complicated) Do some stuff quickly Wait idly for a long time (your favorite mechanism here) Go to step 2. Is there a way to encourage or force the JVM to flush its memory out to disk during long periods of idleness? (e....