java

Distributed Concurrency Control

I've been working on this for a few days now, and I've found several solutions but none of them incredibly simple or lightweight. The problem is basically this: We have a cluster of 10 machines, each of which is running the same software on a multithreaded ESB platform. I can deal with concurrency issues between threads on the same mac...

Using openssl encryption with Java

Hi, I have a legacy C++ module that offers encryption/decryption using the openssl library (DES encryption). I'm trying to translate that code into java, and I don't want to rely on a DLL, JNI, etc... C++ code looks like: des_string_to_key(reinterpret_cast<const char *>(key1), &initkey); des_string_to_key(reinterpret_cast<const char *>...

Elapsed time without considering weekends and bank holidays in Java

I've implemented a stopwatch that works fine without considering that bank holidays and weekends shouldn't be counted in the total duration. I was looking for some open-source library where I could get the elapsed time, passing a start instant, end instant and a set of bank holidays (weekends aren't counted in). The only library that mak...

Abstract Syntax Tree

I have an AST derived from the ANTLR Parser Generator for Java. What I want to do is somehow construct a control flow graph of the source code, where each statement or expression is a unique Node. I understand there must be some recursiveness to this identification, I was wondering what you would suggest as the best option and if ANTLR h...

Tips on walking through unfamiliar code or info on tools that help the process?

I would love tips on how to walk unfamiliar code with many objects. Before OOP this was still a difficult thing and I would do it with listings and have tabs and 8 fingers holding my place. With multiple monitors I have advanced my techniques so it's easier but still difficult. Eclipse does a pretty good job with letting you jump to ...

How do I present text vertically in a JLabel ? (Java 1.6)

I'm looking to have text display vertically, first letter at the bottom, last letter at the top, within a JLabel. Is this possible? ...

Are Java 6's performance improvements in the JDK, JVM, or both?

I've been wondering about the performance improvements touted in Java SE 6 - is it in the compiler or the runtime? Put another way, would a Java 5 application compiled by JDK 6 see an improvement run under JSE 5 (indicating improved compiler optimization)? Would a Java 5 application compiled by JDK 5 see an improvement run under JSE 6 (i...

Why can't strings be mutable in Java and .NET?

Why is it that they decided to make string immutable in Java and .NET (and some other languages)? Why didn't they make it mutable? ...

Java jvm parameters

Does someone know if it's possible to modify the jvm settings at runtime (e.g. -dname=value) ? I need this little trick to run my java stored procedure (oracle 10g)... Thanks a lot. P.S.Sorry for my bad English. ...

How can I set a timeout against a BufferedReader based upon a URLConnection in Java?

I want to read the contents of a URL but don't want to "hang" if the URL is unresponsive. I've created a BufferedReader using the URL... URL theURL = new URL(url); URLConnection urlConn = theURL.openConnection(); urlConn.setDoOutput(true); BufferedReader urlReader = new BufferedReader(newInputStreamReader(urlConn.getInputStream())); ...

test attribute in JSTL <c:if> tag

Hi, I saw some code like the following in a JSP <c:if test="<%=request.isUserInRole(RoleEnum.USER.getCode())%>"> <li>user</li> </c:if> My confusion is over the "=" that appears in the value of the test attribute. My understanding was that anything included within <%= %> is printed to the output, but surely the value assigned to t...

How do you query object collections in Java (Criteria/SQL-like)?

Suppose you have a collection of a few hundred in-memory objects and you need to query this List to return objects matching some SQL or Criteria like query. For example, you might have a List of Car objects and you want to return all cars made during the 1960s, with a license plate that starts with AZ, ordered by the name of the car mode...

Java: Reading an ASCII file with FileChannel and ByteArrays.

I have the following code: String inputFile = "somefile.txt"; FileInputStream in = new FileInputStream(inputFile); FileChannel ch = in.getChannel(); ByteBuffer buf = ByteBuffer.allocateDirect(BUFSIZE); // BUFSIZE = 256 /* read the file into a buffer, 256 bytes at a time */ int rd; while ( (rd = ch...

symbian application as background process

is it possible to create java application that will work as background process on symbian smartphones? ...

Do you generate code? If so, what do you use and what do you generate?

I've used MyGeneration, and I love it for generating code that uses Data Access Applicaiton Blocks from Microsoft for my Data Access Layer, and keeping my database concepts in sync with the domain I am modeling. Although, it took a steeper than expected learning curve one weekend to make it productive. I'm wondering what others are doi...

Stripping Invalid XML characters in Java

I have an XML file that's the output from a database. I'm using the Java SAX parser to parse the XML and output it in a different format. The XML contains some invalid characters and the parser is throwing errors like 'Invalid Unicode character (0x5)' Is there a good way to strip all these characters out besides pre-processing the fil...

Bit manipulation and output in Java

If you have binary strings (literally String objects that contain only 1's and 0's), how would you output them as bits into a file? This is for a text compressor I was working on; it's still bugging me, and it'd be nice to finally get it working. Thanks! ...

How can you run Javascript using Rhino for Java in a sandbox?

Part of our java application needs to run javascript that is written by non-developers. These non-developers are using javascript for data formatting. (Simple logic and string concatenation mostly). My question is how can I setup the execution of these scripts to make sure scripting errors don't have a major negative impact on the rest...

How do you maintain java webapps in different staging environments?

You might have a set of properties that is used on the developer machine, which varies from developer to developer, another set for a staging environment, and yet another for the production environment. In a Spring application you may also have beans that you want to load in a local environment but not in a production environment, and ...

What conferences do you attend?

What conferences do any of you attend? I'm personally interested in both Linux/System Administration and Java conferences, but experiences about any conference are welcome as well. If you have been to any to any, what was your opinion, and were they worth the money? ...