java

How to back up the embedded H2 database engine while it is running?

I would like to build up an web application with H2 database engine. However, I still don't know how to back up the data while the database is running after reading this tutorial: http://www.h2database.com/html/tutorial.html#upgrade_backup_restore Does H2 output its stored file to somewhere in the file system? Can I just back up the ou...

How to think about Java Threads? aka Thread.stop

Exposition: I think the Java VM is awesome. It's guarantee of the safety of bytecode, the the standard libraries, ... are amazing, especially the ability to load a Java class on the fly, and know that it can't crash the VM (good luck with *.so files or kernel modules). One thing I don't understand, is how Java treats Thread.stop I've ...

How to change pitch continuously in Java sound?

I'm working with midi using the Java sound API. Basically I'm trying to achieve a portamento effect where I can slide between different notes. The closest I've gotten is using the setPitchBend() method in MidiChannel. However, this only allows a range of 2 semitones from the note I started with. Is there another way to achieve this porta...

Libraries for writting imap mail _server_ in Java

I've read this: http://java.sun.com/products/javamail/javadocs/com/sun/mail/imap/package-summary.html I want to write an imap server rather than imap client in Java. What libraries should I be looking into? Thanks! ...

Java, C++, NIO, mmaped buffer, synchronization

Exposition: I am on Linux / Mac. Part of my code is in Java, part of my code is in C++. They both have the same file mmapped for fast communication. I want to synchronize the Java & C++ code. I know the following: 1) given two threads in Java, I can use Locks / monitors. 2) given one piece of code in Java, one in C++, I can have t...

Building a jar with MySQL jdbc on solaris

Hi All, Im building a java application that uses JDBC to connect to MySQL. I have an ant script that compiles my code and then packages it, along with log4j, junit, libshout-java and the mysql jdbc driver into one executable jar. This all works fine on ubuntu 9.10, and my code connects to mysql and away we go. However my production env...

.NET to Java code transform

Hi all, I know about IKVM.NET that converts Java bytecode to .NET CIL. Is there a tool that performs reverse conversion? either with or without support for translating WinForms to JavaFX/Swing GUIs. Thanks. ...

java polymorphism

Consider the following code: public abstract class Base { public void getAnswer(); } public class Derived1 extends Base { public void getAnswer() { } } public class Derived2 extends Base { public void getAnswer() { } } public class Main { public final int DERIVED1 = 1; public final int DERIV...

How to read a text file via FTP

I am creating an application for the android, and would like it to be able to read a text file via anonymous FTP. I've tried URLConnection, but it doesn't seam to be working. After some Google searching it appears that URLConnection doesn't always work with some FTP servers. All of the java FTP connection libraries I've found require ...

How to run all JUnit tests of a given package?

I use JUnit 4 in eclipse. I have some test classes in my package and want to run them all. How? ...

get FileChannel without using java.io.* (use pure NIO)

Recently I got a comment to this answer that I should stay away from java.io if I want to use "pure NIO". This is the simplified code (copy a file): private static void copy(File source, File destination) throws IOException { long length = source.length(); FileChannel input = new FileInputStream(source).getChannel(); FileCha...

Simple ArrayList question

I have this class: public class User { public User(String nickname, String ipAddress) { nickname = nickname.toLowerCase(); System.out.println(nickname + " " + ipAddress); } } And another class that creates an array containing User objects. class UserMananger { static User user; static User user2; ...

tutorial on getters and setters?

im from the php world. are there good tutorials explaining what getters and setters are and could give you some examples? ...

annotation = comment?

do they by annotation mean a comment in a code with // or /* */? ...

Recompile decompiled Java (JD / JAD) source that contains goto instructions

(Related question: http://stackoverflow.com/questions/992930/java-compilers-or-jvm-languages-that-support-goto) I have decompiled a jar (Legally, for debugging purposes) and want to recompile it. I've used both JAD and JD and both don't compile due to goto instructions E.g. goto _L1 ... L1: return true; Is...

Eclipse IAutoEditStrategy only called on backspace; how to have it called on all edits?

I am currently working on a custom editor plugin for Eclipse. I've overwritten getAutoEditStrategies like this: public IAutoEditStrategy[] getAutoEditStrategies( ISourceViewer sourceViewer, String contentType) { return new IAutoEditStrategy[] { new KRLAutoEditStrategy() }; } and written a minimal Strategy like this: public class ...

null pointer exception help

I'm getting a NullPointerException that I couldnt handle. I'm a newbie in java so I'd appreciate any help. <% Employee employees[] = (Employee []) request.getAttribute("arr"); Integer arr_size= (Integer) request.getAttribute("arr_size"); for(int i=0;i<employees.length;i++){ %> <tr><td><b>.</b></td><td><%=employees[i].getName()%></td><td...

Can I run a server/client program like this?

Hi, I want to write a yahoo! messenger and I create 2 java applications .one is for "server" and the other one is for" client" .at first I run the Server application and then I will run my GUI frame which is in my client application(So I will run my client application):it will show a frame that gets user name and password from a client ....

How to write a generic method in Java

How to write a generic method in Java. In C# I would do this public static T Resolve<T>() { return (T) new object(); } Whats the equivalent in Java? ...

Java Swing: dispose() a JFrame does not clear its controls

I have a closeWindow() method which uses dispose() for the current JFrame to close down. When I show the window again, the controls (textboxes, lists, tables etc.) still have their previous values in place that were there when I dispose():d the frame... Why is that? Is there another way to completley close and clear a frame? This is the...