java

Is java Runtime.exec(String[]) platform independent?

I had some code that ran commands through Runtime.getRuntime.exec(String), and it worked on Windows. When I moved the code to Linux, it broke, and the only way of fixing it was to switch to the exec(String[]) version. If I leave things this way, will the code work the same on Windows and Linux, or should I use the exec(String) on Windows...

Working with Java's BigInteger probable primes

I want to print all the prime numbers between two numbers. This is my code: package sphere; import java.math.BigInteger; import java.io.*; class PrimeTest2 { public static void main(String args[]) throws java.lang.Exception { BufferedReader r = new BufferedReader(new InputStreamReader(System.in)); String s = r.read...

Java Date - Insert into database

Hi all, I need to figure out a way to insert a record with a java.util.Date field into a database and i'm stuck. Does anyone know how i can do this? Right now i have something like. java.util.Date myDate = new java.util.Date("01/01/2009"); sb.append("INSERT INTO USERS"); sb.append("(USER_ID, FIRST_NAME, LAST_N...

What is an effective way to track, identify and report every 'error message' raised by your application?

In case management and workflow systems this seems to come up a lot. The need to provide a comprehensive list of each business message in the 'system' and provide its possible cause(s) and corrective action(s). A vendor example is Oracle: All their errors have a naming convention (e.g. ORA-00237) and they have documented every possi...

Iterating over a data structure with 51 million primes quickly.

What's the best data structure (in java) for the task of loading 51 million primes and then iterating over them? I need to know, for example, the primes that are between 1000000000 and that same number minus 100000. ...

Java Documentation Override Method does not InheritDoc

A method that overrides another method does not inherit documentation of the method it is overriding. Is there any way to explicitly tell it to inherit the documentation? /** * {@inheritDoc} * * This implementation uses a dynamic programming approach. */ @Override public int[] a(int b) { return null; } ...

Limit CPU / Stack for Java method call?

I am using an NLP library (Stanford NER) that throws OOM errors for rare input documents. I plan to eventually isolate these documents and figure out what about them causes the errors, but this is hard to do (I'm running in Hadoop, so I just know the error occurs 17% through split 379/500 or something like that). As an interim solution,...

Setting background color for the JFrame

how to set a background color for the jframe ??? ...

Does java have attributes like C#?

I wonder if they have attributes now and their similarities with this C#'s powerful feature. ...

RMI ClassNotFoundException

Encountering UnmarshalException ClassNotFoundException in RMI while attempting to revoke Remote Method in Netbeans 6.5/windows xp. Both rmi client and server programs are running in the same machine. RMI Client Program: Source Code Location F:\NewRMIClient\src\newrmiclient\RMIClient.java F:\NewRMIClient\src\newrmiclient\RemoteInterfa...

Looking for a Meta Logging Framework

I am looking for a library that does logging on a higher abstraction layer then Log4J or similiar. Instead of calling the framework once for every row of logging needed, I want to call it once per at the beginning of the action, once at the successful ending and possibly once if an exception occured. The logging framework should then c...

Efficient way of reading a file

how to read a file in an efficient way in java?? suggest any methods.. i used BufferedReader,which is very slow.. suggest any changes?? CODE: import java.io.*; import java.awt.; import javax.swing.; import java.awt.event.*; import java.lang.StringBuffer; /The main class file starts here/ class TitleCaseRow10 extends JFrame implemen...

Best practices for writing open source Java

Where can I find some best practices for writing open source Java code? I'm not looking for directions on how to write the code proper, but rather on distribution, packaging, documentation, and all the other aspects besides .java files. My goal is to take a module I've written and publish it as open source. Edit - I'm still missing dir...

Linking to an external URL in Javadoc?

Something like: /** * See {@linktourl http://google.com} */ ...

How to remove entity with ManyToMany relationship in JPA (and corresponding join table rows)?

Let's say I have two entities Group and User. Evety user can vbe member of many groups and every group can have many users. @Entity public class User { @ManyToMany Set<Group> groups; //... } @Entity public class Group { @ManyToMany(mappedBy="groups") Set<User> users; //... } Now I want to remove group (let's s...

What is the best database to use with a java program?

I've been struggling to get a Java program to connect to MS SQL Server, and I'm starting to wonder if MySQL would be a better choice for my (learning) project. Sun's tutorials refer to Java DB, but I've never heard of that in any other context, so it seems not the most useful database to learn about. I appreciate any insight into the m...

How to gain Java web programming experience?

Hi everyone! I'm wondering, how do I gain relevant professional experience on Java web programming? It seems to be the requirement for every job ad I see. I currently work as a PHP programmer on a small company. I have no CS degree but I'm doing ok on my job. I spend my free time (and enjoy it) studying Java. After some time I learned S...

Is it better to keep libraries in the application lib or in common/lib?

I'm doing some Spring development and I'm trying to decide if libraries should always be kept in the application lib, even if they end up being common to more than one app. Doesn't Tomcat startup slowdown if a bunch of jar files end up in the common/lib? I'm also fearful of versions and dependencies. Isn't that less of a problem if the a...

Where can I find a Java library for code highlighting?

I'm trying to find a Java library to highlight code. I don't want to highlight Java code. I want a library that will easily allow me to highlight a macro language of my own, in a code editor of my own written in Java. ...

What JEditorPane event should I create a listener for?

Suppose I have a JEditorPane in a JPanel. I want to be able to execute a callback each time the user enters/pastes text in the JEditorPane component. What type of listener should I create? ...