java

What do -XX:-PrintGC and XX:-PrintGCDetails flags do?

I found the JVM flags here. Is there a more detailed explaination of what exactly they do? ...

Why doesn't this for-loop let me input text the first cycle?

What I want to do is ask the user for a number of strings to read into an array, and then ask the user to input that number of strings and read them into the array. When I run this code it never asks me for an input the first cycle of the first for-loop, just prints out "String #0: String #1: " and then I can input text. Why is that and ...

Java: Implementing simple equation

I am looking to implement the simple equation: i,j = -Q ± √(Q2-4PR) / 2P To do so I have the following code (note: P = 10. Q = 7. R = 10): //Q*Q – 4PR = -351 mod 11 = -10 mod 11 = 1, √1 = 1 double test = Math.sqrt(modulo(((Q*Q) - ((4*P)*R)))); // Works, but why *-10 needed? i = (int)(((-Q+test)/(P*2))*-10); // ...

How to generate JAVA RMI stubs and skeletons from Interface?

Is there an action (menu / shortcut) that I miss or plug-in to add to a basic JavaEE distribution of Eclipse 3.5 that will allow to generate / regenerate files that usualy done from command line call for rmic? I am aware of the "RMI Plug-in for Eclipse version 2.0" I am looking for a free one. ...

Hibernate, aliases

Hello! I noticed that hibernate generates different aliases for the same columns each time i try to access the same table: Hibernate: select person0_.id as id0_0_, person0_.nam as nam0_0_, person0_.fam as fam0_0_, person0_.otc as otc0_0_ from web_db.Person person0_ where person0_.id=? Hibernate: select person0_.id as id4_0_, person0_.n...

Android NDK: Autogenerate function declarations?

I am trying to use a pre-existing native C library in my android project.. The library builds just fine with the NDK tools... Now what I've come to understand is that I cannot just call into the library, but my library needs to include jni.h and add specific function declarations, like for example: JNIEXPORT jint JNICALL Java_com_MultP...

The buttons are working but they are interacting with the compiler not the gui?

Im guessing my buttons are right, but when clicked they add integers on the compiler and subtract integers using the next and previous buttons. i want them to scroll through the contacts on the file i have connected? public void nextContact() { if(index < details.size() - 1) { ...

generic programming in java

I have some confusion about generic programming in java: If Manager is subclass of Employee, Collection<Manager> managers=new Collection<Manager>; Collection<Employee> employees=managers;//why illegal? Why the last statement is illegal? Since according to illustration in the book CORE JAVA,after the erasion,Collection<Manager> and...

deleting lines from a file

I need to delete certain lines from a file, the file is a list of contacts that I read in from a file into my GUI. When I get to the contact I want to delete, my program should delete the contact from the file. I've tried to do this, but it is not working. Here is the code I'm currently using: String temp=txtname.getText(); for (Cont...

How to implement ConcurrentHashMap with features similar in LinkedHashMap?

I have used LinkedHashMap with accessOrder true along with allowing a maximum of 500 entries at any time as the LRU cache for data. But due to scalability issues I want to move on to some thread-safe alternative. ConcurrentHashMap seems good in that regard, but lacks the features of accessOrder and removeEldestEntry(Map.Entry e) found in...

Java Server Side App, How to?

I am building a scalable Server Side App in Java but I need to know the "Do's and the Dont's". The app needs clients to connect to the server via TCP Sockets, I heard lot of good things about Apache MINA so I thought I'd give it a try and build around this. I would also need the app to communicate to a Database and send suitable dat...

Finding Highest Order 1 in a Java Primitive

I need to find the highest order 1 in some longs, ints, and shorts in Java. For example, if I had a char that looked like 00110101, I need a method that will return 2 (index of highest order 1). Now, I know that you can do this using a for loop like: for(int i=0; i<8; i++) if((x & 1<<i) != 0) return i; return -1; but this is way ...

What's the idiomatic way to turn a single char into a string in Java?

Right now I'm using the following to minimize boxed object creation: String myString = "" + myChar; Is this the idiomatic way to do it? (IMHO it feels a little awkward.) ...

Java for loop to create n amount of object

I need some help. I want to create a for loop that creates n number of objects of a class, and then adds them into an arraylist. Something like this: //Player is a custom class ArrayList<Player> numberofPlayersArray; numberofPlayersArray = new ArrayList<Player>(); //n is a variable for the number of Player class objects that I want to...

Arrays: Counting, Comparing and Increase

Woohoo, I've come to arrays now, thank god. Now, I've got 2 arrays! int colorvalues[][] = {{34,255,255,56},{127,204,11,34},{123,98,127,34},{34,34,127,17}}; Imagine it as a 4x4 pixel picture Now, I want to create a histogram, the distribution of colorvalues from 0 to 255. For example here I've 2*255, 2*127, 5*34 and so on. So I've ...

Separate web.xml for development and production

Hello! My web.xml is different in devel and production environments. For example in development environment there is no need in security constraints. Typically I deploy new application version as follows: Export Eclipse project to WAR. Upload WAR to the server. Redeploy. The problem is that I have to manually uncomment security con...

Using HttpCore from a blackberry

I am trying to port an android app to run on a blackberry 8800. One of the classes makes http requests through apache HttpCore. I get the following error: The type java.lang.reflect.Type cannot be resolved. It is indirectly referenced from required .class files ProjectFoo-BBerry/src/com/projectfoo/ws/rest/ProjectFooClient.java (line 1...

Introduction to Java Graphics Libraries

I just got into information-visualization and scientific-visualization and have been using Piccolo and a little with JFreeChart. I am trying to find a few new libraries that I can start using. I am looking specifically for libraries that involve multi-dimensional visualization and map overlaying (something like open-layers), but would be...

How to compress an FLV movie in java?

How can we compress the flv movie? Is there any free library which i can use? for compressing the video i can go for reducing the resoultion as well, even framerate reducing is acceptable to me. ...

encryption/decryption & java - basic questions

I have to implement the following scenario. User calls a webservice sending a request with a text which must be encrypted by my service if it isn't encrypted. After that it should be stored in the database. Is it a good idea to declare this attribute in xsd as String or is it a better type? Should I allow to use CDATA? Using Jaxb I wi...