java

increasing heap size in netbeans.conf file

I was reading in netbeans 6, you don't have to set the maximum heap size, it will just look at your computer for that information. My system has 8 gigs of ram, but my application only has 64mb to play with and it is running out of memory. I did a: System.out.println(Runtime.getRuntime().maxMemory()); And it is 66 650 112 bytes (63.56...

Installer/packager for a Java application for Ubuntu and SuSE

I have a Java application complied to a collection of jars that I want to make installable on Ubuntu and SuSE. I Want the installer to be able to check for the JRE, register a file association and be able to load a website on un-install. I understand Ubuntu and SuSE are based on different architectures, so is there a consistent way to d...

how to set query to be read uncommited?

with hibernate, how can I set a query to be read uncommitted? I don't want this to be a global setting, just want to do it on a per query basis. ...

before calling session.gettransaction, do I have to ensure one exists?

before calling session.gettransaction, do I have to ensure one exists? if so, how do I check if there is a current uncommitted transaction in the session? ...

Is there a javadoc tag for documentating generic type parameters?

I've been looking through the javadoc documentation on Sun's site, trying to find if there's a javadoc tag which can be used to document a class or method's generic type signature. Something like @typeparam, similar to the usual @param, but applicable to types as well as methods,e.g. /** * @typeparam T This describes my type paramete...

Unbounded wildcards in Java

Is there ever a difference between an unbounded wildcard e.g. <?> and a bounded wildcard whose bound is Object, e.g. <? extends Object>? I recall reading somewhere that there was a difference in the early drafts of generics, but cannot find that source anymore. ...

What is the easiest way to parallelize a task in java?

Say I have a task like: for(Object object: objects) { Result result = compute(objects); list.add(result); } What is the easiest way to parallelize each compute() (assuming they are already parallelizable)? I do not need an answer that matches strictly the code above, just a general answer. But if you need more info: my tasks ...

How to configure Spring JavaMailSenderImpl for Gmail

I am trying to find the correct properties to use to connect to the Gmail SMTP sever using the JavaMailSenderImpl class. Let me first say that I have tried the approach found here. This worked fine. But when I tried the configuration below that post with the exact same authentication information I received a javax.mail.AuthenticationF...

Sensitive Data In Memory

I'm working on a Java password manager and I currently have all of the user's data, after being decrypted from a file, sitting around in memory at all times and stored plainly as a String for displaying in the UI etc. Is this a security risk in any way? I'm particularly concerned with someone "dumping" or reading the computer's memory i...

Does Java have a using statement ?

Does Java have a using statement that can be used when opening a session in hibernate? In C# it is something like: using (var session = new Session()) { } So the object goes out of scope and closes automatically. ...

Illegal Argument Exception in Google Wave App

I'm writing a Google Wave robot and I just messed something up. It was working just fine but now I'm getting an IllegalArgument exception on the line that includes query.execute. Am I doing something stupid? I've seen several code samples very similar to what I'm doing. I can include the code of the WaveUpdate class if necessary. Th...

Is it possible to get a reference to a Java method to invoke it later?

Is it possible to obtain references to an object's methods? For example, I'd like to have a method that invokes other methods as callbacks. Something like: public class Whatever { public void myMethod(Method m,Object args[]) { } } Is this possible? EDIT: I meant an object's methods. I take it it's not possible? ...

Java polymorphism/abstract class help

I'm trying to set parameters for a abstract class: public abstract class NewMath { public abstract int op (int intOne, int intTwo); } Here is the extended subclass: public class MultMath extends NewMath { public int op (int intOne, int intTwo){ return intOne + intTwo; } } But when I try to instantiate an object ...

Garbage collection in Java

Exposition: In general, Reference Counting has the weakness of "it can't detect loops." However, in some cases, Reference Counting is really useful: class EmergencyPatient { DoctorPtr doctor; EmergencyPatient() { doctor = Doctor::acquire(); } ~EmergencyPatient() { Doctor::release(doctor); } }; Now, in a reference counted world...

synchronized(Object) { } problems

I have ran into a perfomance problem where 880 threads are doing synchronized() { method() } in the same time and this has lead to a major perfomance problem. Is it possible that there is some limit of threads waiting at synchronized()? Where can I get the limit? Another question is what is best to put into synchronized( ? ). Because ...

Java concurrency question - synchronizing on a collection

Will the following code snippet of a synchronized ArrayList work in a multi-threaded environment? class MyList { private final ArrayList<String> internalList = new ArrayList<String>(); void add(String newValue) { synchronized (internalList) { internalList.add(newValue); } } boolean find(Stri...

Changing SQL token generator to Java token generator

I have a MySql database with a users table. In this table is a random token that is being used for security reasons. Until now, we have been adding users by manually adding rows; The token was created using MD5(Rand()). I will now be adding users programmatically doing something like principal.setToken(whatever). What is the easiest wa...

does continue work in a do while?

I have a do while that looks like: User user = userDao.Get(1); do { // processing // get the next user // user = UserDao.GetNext(user.Id); if(user == null) continue; // will this work????????????? } while ( user != null) If it does work, its going to go to the top of the do statement, and user is null so things are g...

Java JTabbedPane questions

I'm using a JTabbedPane to hold each step in the wizard that I am building. Navigation between steps is doing using the Previous/Next buttons or by selecting a tab. The buttons decrement/increment the JTabbedPane's SelectedIndex. I need to validate each step before proceeding to the next step. Essentially, I'm having difficulty deter...

ClassCastException when casting object Array to Long array

I get this exception when i try to cast an Object array to a Long array. Exception in thread "main" java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Ljava.lang.Long; My keys in my hotelRooms map are Long, why it is not possible to cast. Does someone know how to solve this. public class ObjectArrayToLong...