The idea is to define a base class that can invoke methods defined in derrived classes, but at creation time I want to ensure, that such methods are defined exactly according to the requirements, which is that the methods take only one argument, a HashMap<String String>.
So far I was able with the following code to check that the method...
How to implement a panel that would support line wrapping and line breaking?
I would only add textual labels and line breaks to this panel.
The labels should flow from left to right, wrapping to the next "line" if
needed. The line breaks would cause a jump to the next line.
I would also like to make the panel vertically scrollable.
The ...
Hi,
I got following exception when I am trying to seek to some file.
>
Error while seeking to 38128 in myFile, File length: 85742
java.io.EOFException
at java.io.RandomAccessFile.readInt(RandomAccessFile.java:725)
at java.io.RandomAccessFile.readLong(RandomAccessFile.java:758)
>
But If you see I am trying to seek...
I have heard from people who swear by one or the other. Both are full-featured, excellent IDEs. But each has slightly different strengths. This is not meant to turn into a holy IDE war. Please downvote any flamebait answers. Thanks.
This is the analog of this question.
...
Is there a max. size you can set Xmx to? I set it to 1024m and eclipse opens ok. When I set it above 1024, eclipse doesn't open and I get the error "jvm terminated. Exit code=-1"...
I was doing this because I keep getting an "java.lang.OutOfMemoryError: Java heap space". I am reading in a 35.5Mb .txt file and this error occurs when it's...
I have a really strange enum bug in Java.
for(Answer ans : assessmentResult.getAnswersAsList()) { //originally stored in a table
//AnswerStatus stat = ans.getStatus();
if (ans.getStatus() == AnswerStatus.NOT_ASSESSED) {
assessed = false;
}
}
An answer is an answer to a question on a test. An assessment result is th...
Hi All,
I'm trying to run my junit tests using ant. The tests are kicked off using a JUnit 4 test suite. If I run this direct from Eclipse the tests complete without error. However if I run it from ant then many of the tests fail with this error repeated over and over until the junit task crashes.
[junit] java.util.zip.ZipExcept...
My Java application is started from within a native program through java.dll. This native program is launched as a service on Windows.
The following options have been added to the JVM args for remote debugging:
-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n
In this configuration, it is impossible to c...
Hi,
I'm setting up a continuous integration server (Hudson) to build a Java project and run the relevant unit/integration tests. Most of these tests access a database and the test data is kept in a DbUnit XML file.
I'm looking for a way to automatically keep the test database schema up-to-date. Currently the SQL script for a particular...
Hi,
I have a seemingly simple problem though i am unable to get my head around it.
Let's say i have the following string: 'abcabcabcabc' and i want to get the last occurrence of 'ab'. Is there a way i can do this without looping through all the other 'ab's from the beginning of the string?
I read about anchoring the end of the string ...
Hi!
I've got a question about testing methods working on strings. Everytime, I write a new test on a method that has a string as a parameter.
Now, some issues come up:
How to include a test string with \n, \r, \t, umlauts etc?
How to set the encoding?
Should I use external files that are opened by a FileInputStream? (too much overhea...
Hello,
I am really thankful for everyone who would read this and try to help me, the following is the code I am trying to write for a server class for a socket-programming project for college:
import java.io.*;
import java.net.*;
import java.io.File;
class Server{
public static void main (String[]args)throws IOException{
Serve...
We are currently trying to implement a web application which is using the J2EE authentication mechanism with a FORM-based login, inside the Websphere 6.1 web container. If the authentication is successful, we have everything working; the LDAP membership groups are being retrieved, the group to role mapping is being performed, and the ro...
This is a poll of sorts about common concurrency problems in Java. An example might be the classic deadlock or race condition or perhaps EDT threading bugs in Swing. I'm interested both in a breadth of possible issues but also in what issues are most common. So, please leave one specific answer of a Java concurrency bug per comment an...
If I wanted to implement a regex engine in JavaME (Which lacks the regex libraries), where would be the best place to start? I'm imagining there is existing regex code out there which it would be possible to use as a starting point for porting.
Failing that, a good guide on how to compile and execute a regular expression would do.
...
I have the following interface:
public interface Result<T extends Serializable> extends Serializable{
T getResult();
}
With that interface, I can not define a variable of type
Result<List<Integer>>
because List is not serializable.
However, if I change the interface to this:
public interface Result<T> extends Serializable{
...
As an example:
public class Foo {
private Foo() {}
}
public class Bar extends Foo {
private Bar() {}
static public doSomething() {
}
}
That's a compilation error right there. A class needs to, at least, implicitly call its superclass's default constructor, which in this case is isn't visible in Foo.
Can I call Objec...
Hi,
On my Windows machine, my main hard drive has the letter C: and the name "Local disk".
To list the drive letters in Java on Windows, the File object has the static listRoots() method. But I can't find a way to acquire the drive names (as opposed to the drive letters) on Windows.
Has anyone tried this before?
Thanks,
Mattijs
...
From what I have gathered, I want to force a class to use particular private fields (and methods) I need an abstract class because an interface only declares public/static/final fields and methods. Correct??
I just started my first big java project and want to make sure I'm not going to hurt myself later :)
...
I'm not sure if there is a way to do this in Velocity or not:
I have a User POJO which a property named Status, which looks like an enum (but it is not, since I am stuck on Java 1.4), the definition looks something like this:
public class User {
// default status to User
private Status status = Status.USER;
public void s...