java

Checking for odd cycles in an undirected graph

Hello, I'm back with another similar question. I am currently working on a Java program that will check if a graph is 2-colorable, i.e. if it contains no odd cycles (cycles of odd number length). The entire algorithm is supposed to run in O(V+E) time (V being all vertices and E being all edges in the graph). My current algorithm does a D...

Cache java compilation

Is there any posibility to cache java compilation like ccache does for C or C++ compilation? I have a lot code to compile, and I compile the same code many times, so it took a lot of time. So I thought to cached it to speed up. ...

Two Applets in same page

I am trying to put two applets which share same code base but initialized with different paramaters in same web page. process goes like this: applet.jar->create two applet tags, with different parameters, same jar in a page->deploy to server->access the page. HTML looks like this: <HTML> <HEAD> <TITLE>Java applet example - Passing a...

MD5 Hash of ISO-8859-1 string in Java

I'm implementing an interface for digital payment service called Suomen Verkkomaksut. The information about the payment is sent to them via HTML form. To ensure that no one messes with the information during the transfer a MD5 hash is calculated at both ends with a special key that is not sent to them. My problem is that for some reason...

Encryption and Java, method generating key - what size?

I got the following method body to generate a key for encryption: new BigInteger(500, new SecureRandom()).toString(64); Could anyone explain what is the size of generated key? ...

Howto make JButton with simple flat style?

Hi, whats the most simple way to make a JButton only show the background color? I don't need any other effects like borders, 3D-look or hover-highlighting. Thanks in advance. ...

What Java-Web-Framework to use if JSF is oversized?

Hi, we think about to move a project from PHP to Java. It's a small web application with about 5 pages. We have JSF-experience, but i think JSF will be oversized and too cumbersome (we will massivly make use of JS). What can you recommend? GWT? ...

Mutually Exclusive CellEditors in JTable

I currently have a problem whereby editing the contents of one cell in a JTable alters the content of another; two of the columns are mutually exclusive. They are both checkboxes. At the moment, if I alter one cell, it isn't until the other is redrawn that it updates. Therefore, both cells in the row can be displayed as being selected a...

Tool for monitoring Hibernate cache usage

Is there any tool which would allow for monitoring Hibernate 2nd level cache usage? I know that I could use Hibernate API for retrieving such information. But what should I do when I have application which doesn't read the information itself, and I can't modify it? Is there any way to read cache statistics from the outside of the applica...

Calling webservice via server causes java.net.MalformedURLException: no protocol

I am writing a web-service, which parses an xml file. In the client, I read the whole content of the xml into a String then I give it to the web-service. If I run my web-service with main as a Java-Application (for tests) there is no problem, no error messages. However when I try to call it via the server, I get the following error: j...

Is there a way to declare a method "friendly" in Java?

Hi, I know that attributes can be set public, friendly or private to specify its visibility. Is there a way I can declare a friendly method? I want it to be accessible only from objects of classes of the same package. Thanks you, a beginner here :(. ...

ActiveMQ: how to dequeue older messages?

Hi, I'm learning how to use ActiveMQ and now we are facing the following problem. Suppose that I have a topic named topic.test on ActiveMQ which have two subscribers. In a given moment, I have only one of those subscribers waiting for messages, and a producer send a message for the topic I mentioned above. Ok, the connected subscriber...

Can a BFILE locator point to a directory on a different filer?

I have a java web application which needs to upload files and we want to store these files on the filesystem rather than in the database. The database will store the document metadata only. The question is whether to just store the path as a string in Oracle, or as a BFILE locator? Can a BFILE locator point to a location which is on a d...

When should I use the JDBC Persistence Adapter in ActiveMQ?

Hi, reading the ActiveMQ documentation (we are using the 5.3 release) I find a section about the possibility of using a JDBC persistence adapter with ActiveMQ. What are the bennefits? Does it provide any gain in performance or reliability? When should I use it? ...

Analyze GC logs for Sun Hotspots, JVM 6

I'm trying to analyze GC behaviour for our application (running in Tomcat, under Sun's Hotspots, JVM 1.6). So far I've: Instructed the JVM to emit GC logs to a separate file using: -Xloggc:gc.log -XX:+PrintGCApplicationStoppedTime -XX:+PrintGCApplicationConcurrentTime -XX:+PrintGC -XX:+PrintGCTimeStamps -XX:+PrintGCDetails ...

Tomcat Valve settings

Hi %, I'm stuck with sort of a configuration issue I think. I need to protect a folder which is within my actual tomcat application from access from a certain IP range. I thought this was serverfault, so I posted the question there. Right now I'm not sure whether this is SO or SF anyways... Nevertheless I kept on trying geting it goin...

How to configure log4j to log different log levels to different files for the same logger

I have a normal INFO level log for application. What I need is to additionally log all ERROR level events to separate error log. I am using configuration like this: <logger name="com.acme"> <level value="error"/> <appender-ref ref="error"/> </logger> <logger name="com.acme"> <level value="info"/> </logger> <root> <level value=...

Service with wide API organizational & techincal questions

Here are some task details: The key functionality of service is Java socket-server (based on Red5. I know it might be overkill, but it makes me confident in future) on unix-platform (FreeBSD or Linux Debian, but I suppose, that the last one). Service deals with quite a lot of simple data. Service must have very strong and wise API. We ...

Clearest way to combine two lists into a map (Java)?

It would be nice to use for (String item: list), but it will only iterate through one list, and you'd need an explicit iterator for the other list. Or, you could use an explicit iterator for both. Here's an example of the problem, and a solution using an indexed for loop instead: import java.util.*; public class ListsToMap { static ...

Finding Installed JDBC Drivers

I'm writing a database validation tool in Java and have preference screens so the user can define their database connections. The tool should be able to cope with DB2, Oracle, Postgresql and Mysql as a minimum. What I would really like is to be able to present the user with a list of their installed jdbc drivers as part of this process....