Basically we’ve noticed that on some computers setting the JVM option -Xmx (max heap size) sometimes cause the JVM to fail to initialize, even if there’s more than adequate RAM on the system. So for example, on a 4gb machine, we have -Xmx1024m which fails but -Xmx800m works. I could understand on …
Tag: java
How to define a char stack?
How to define a char stack in java? For example, to create a String stack I can use such construction: But when I’m try to put char instead String I got an error: Answer Using a collection of char is pretty inefficient. (but it works) You could wrap a StringBuilder which is also a mutable collection of …
JSF Keep Parameter in XHTML
How can ı kep parameter in XHMTL file. for example ı want to kep parameter like ….param name= “name” value=”john”…. then the other line ı want to print it with calling name parameter. I want …
Why is there no SortedList in Java?
In Java there are the SortedSet and SortedMap interfaces. Both belong to the Java Collections framework and provide a sorted way to access the elements. However, in my understanding there is no SortedList in Java. You can use java.util.Collections.sort() to sort a list. Any idea why it is designed like that? …
calculate number of weeks in a given year
I would like to get the number of weeks in any given year. Even though 52 is accepted as a generalised worldwide answer, the calendars for 2015, 2020 and 2026 actually have 53 weeks. Is there any way that I can calculate this, or any functions that will help me out? Answer According to the wikipedia article o…
URLjava.io.IOException: Server returned HTTP response code: 411 in JAVA
I’m checking whether internet is available or not While running this code i’m getting the exception URLjava.io.IOException: Server returned HTTP response code: 411 What could be the error. Answer HTTP status code 411 means “length required” – you’ve tried to make a POST req…
Any way to ignore only “connection reset by peer” IOExceptions
I am getting really annoyed with loads of IOExceptions from socket read calls due to network problems. Normally it simply means someone killed the child process or the network went down badly (VPN connection dropped etc). My server cannot do anything but I really dont want to see all these errors in the log f…
Why do I get “must override a superclass method” with @Override?
The following code generates this error message at the public void onClick line. Multiple markers at this line – implements android.view.View.OnClickListener.onClick – The method onClick(View) of type new View.OnClickListener(){} must override a superclass method I can’t understand why. This…
Java Generics and adding numbers together
I would like to generically add numbers in java. I’m running into difficulty because the Numbers class doesn’t really support what I want to do. What I’ve tried so far is this: Obviously this will not work. How can I go about correcting this code so I could be given a list of <int> or …
Limitation while generating excel drop down list with Apache POI
I’m trying to generate an excel file with some validations, I’ve read the poi dev guides for implementing it. During implementation, I got an exception (String literals in formulas can’t be bigger than 255 characters ASCII). POI concatenates all drop down options into ‘0’ delimin…