java

java socket send & receive byte array

in server, I have send a byte array to client through java socket byte[] message = ... ; DataOutputStream dout = new DataOutputStream(client.getOutputStream()); dout.write(message); How can I receive this byte array from client? anyone give me some code example to do this thanks in advance ...

Can a java applet manipulate the HTML page containing it?

Hi, I wanted to know if I can write something on the HTML page containing my Java applet from within the applet. More generally, what interactions are possible between these two? Thanks. ...

Using Multiple ApplicationContexts in Spring - question about cleaning up resources

If I have a main appCtx and then I have a series of separate appCtxs which refer to the main one as the parent, then can I destory the child contexts to free up memory? In effect I want to use the child appCtxs as object caches and I want to have the option of saying to a specific cache - "I'm not using the beans in this cache any more ...

Java Open source helpdesk +workflow project

Any recommendation on which Java open source helpdesk system i should use ? i need these criteria - come with dynamic approval level support for certain request (workflow) ...

Best alternative for .NET nullable value type for Java-consumable service

We are creating some WCF services that will initially be consumed by .NET clients but in the future will be consumed to Java clients. As such we want to avoid using any data types in the interface that Java does not support. The specific one we know of is nullable value types. One suggestion is that we can support these by using a str...

Is there a coding convention for a "line rule" for Java

I like to organize my Java files a little and would like to know if there is a standard way of doing this. For example: public class Example { private int exampleInt; private String exampleString; /*------------------------------------------------------------*/ /* I N N E R C L A S S E S ...

Configurable persistence in Java EE5+

There are 2 ways of using a persistence unit, code or annotation. CODE [..]EntityManagerFactory emf; emf = Persistence.createEntityManagerFactory("SOMEPU");[..] or ANNOTATION [..] @PersistenceContext(name = "persistence/LogicalName", unitName = "SOMEPU") [..] Question: If you want to change the persistence unit (or point to d...

Connecting thousands of clients to a Jabber server through a single connection

We are using Openfire (Jabber) to enable chat and presence capabilities to our MMORPG. In our server architecture clients only open a single connection with the game server, and upon login, the game server creates a new connection to Jabber for this new client. The problem is, we don't want to open a new connection to Jabber for every c...

Can we update a jar / war file in a deployed server and then reload the new jar / war file ?

Can we update a jar / war file in a deployed server and then reload the new jar / war file ? if so how simple we can achieve this, and please if possible list web servers which support this feature. ...

Why does Eclipse compile this, but javac doesn't?

We have some unit tests which compile and run fine in Eclipse 3.4, but when we try to compile them using javac, it fails. I've managed to cut the code down to something small and self-contained, so it has no external dependencies. The code itself won't make much sense because it's all out of context, but that doesn't matter - I just need...

JarFile from inside a *.jar or inputstream to file?

I have a jar or war. I'm programmaticaly reading this jar, and when I find jar inside this jar I'd like to programmaticaly read it again. But JarFile provides only getInputStream, which I cannot pass to JarFile(File file) constructor. How to read jar from jar? EDIT: I was thinking about getting the File somehow from classloader or s...

Where can I find the old "Developer Collaboration" plugin?

Once upon a time there is netbeans plugin called "Developer Collaboration" which allows you make remote pair programming. Now, in Netbeans 6.7, there is no more this "Developer Collaboration" but there something called "Kenai support". Unfortunately Kenai does not seems to have a real time editor and it seems to be usable only for open...

Acronyms in Camel Back

I often see Java class names like XmlReader instead of XMLReader My gut feeling is to completely upper case acronyms, but apparently many people think differently. Or maybe it's just because a lot of code generators are having trouble with acronyms... So i would like to hear the the public opinion. How do you capitalize your class...

Java nonblocking memory allocation

I read somewhere that java can allocate memory for objects in about 12 machine instructions. It's quite impressive for me. As far as I understand one of tricks JVM using is preallocating memory in chunks. This help to minimize number of requests to operating system, which is quite expensive, I guess. But even CAS operations can cost up t...

Converting a 32bpp image to a 16bpp image in Java

How could a 32bpp image ( ARGB ) could be converted to a 16bpp image ( ARGB ) using Java's libraries? For my curiosity, at pixel level, what does this conversion do? If I have an int value that holds the value of a pixel ( with all the channels ), how would that int be different after the conversion had happened? ...

Determine whether client browser has java installed and can launch applets

Hi, I am developing an .aspx page which will ultimately launch an applet after the user clicks on a button (I am using the <applet> tag). So, I would like to detect if java is enabled/installed on the user's browser. I am using navigator.javaEnabled() method. However, even though this is working fine on IE7, it is returning inconsisten...

Slow building list of paths

I'm building a list of hashes that represent root to node paths in a tree. My functions work but they are incredibly slow over large tree structures - is there a better way? I've tried building the list in one function but I get unique hashes where I don't want them. public ArrayList<Integer> makePathList(AbstractTree<String> tree){ ...

Java Logger - "No line break" and "explicit class logging" problem

Hey everybody, I'm currently struggling with two problems about the java.util.logging.Logger: 1) I'd like to have a (convenience-)method like the "info()/fine()" methods, only that those methods should not insert a line break after the output (functionality like System.out.print and println). I've already overridden the format() method ...

Why is capitalising class names in Java (and others) only a suggestion and not a rule?

I am wondering why Java, with its many safety features and constraints, allows developers to start a class name with a lowercase letter even though it would be an extremely stupid idea to do so. Or have I overlooked a case where this could be useful? Or is it simply a case of not bossing the programmer around? ...

Void value as return parameter

I have this interface: public interface Command<T> { T execute(String... args); } it works fine for most uses. But when I try to model a command that have only side effects (e.g. without return value) I'm tempted to write: public class SideEffectCommand implements Command<Void> { @Override public Void execute(String... a...