Suppose I have following code
package memoryleak;
public class MemoryLeak {
public static int size;
static {
size = (int) (Runtime.getRuntime().maxMemory()*0.6);
}
public static void main(String[] args) throws InterruptedException {
{
byte[] data1 = new byte[size];
}
byte[...
First some background information:
We have three environments for our EJB3 application: test, development and production. All require database settings of their own. We use maven2.
Data source settings are placed in ear project, directory /src/main/application/META-INF/data-sources.xml. File contains attributes for three different conn...
Hi,
What is the easiest and correct way to convert a String number with commas (for example: 835,111.2) to a Double instance.
Thanks,
Rod
...
Hi,
My need is terribly simple and yet I can' figure out a simple way to do it.
I have a text file, and I need to print it to a specific network printer. I know the name of the printer.
Until now I have made a Printable class to print my file (ticket).
public class TicketPrintPage implements Printable {
private File ticket;
...
I'm putting together a Swing application where I often want to replace the contents of a JPanel. To do this, I'm calling removeall(), then adding my new content, then calling revalidate().
However I'm finding that the old content is still actually visible (though obscured by the the new content). If I add a call to repaint() in addition...
Sometimes, you just have to catch Throwable, e.g. when writing a dispatcher queue that dispatches generic items and needs to recover from any errors (said dispatcher logs all caught exceptions, but silently, and then execution is continued on other items).
One best practice I can think of is to always rethrow the exception if it's Inter...
please tell me if I am doing something wrong. I want to print barcodes onto labels, so I need high quality printout for these barcodes so I am pushing printer to print in 300dpi. What I've done:
made a big JFrame; width: 2490px, height: 3515px so it represents A4 paper in 1:1 measure (this is A4 paper resolution if print is to be 300...
In C#, I can use the throw; statement to rethrow an exception while preserving the stack trace:
try
{
...
}
catch (Exception e)
{
if (e is FooException)
throw;
}
Is there something like this in Java (that doesn't lose the original stack trace)?
...
I need to automate UI testing of a software that my module is plugged in. I do not have an access to code of the host so I need something like AutoIt. Since AutoIt does not work with Swing, is there any AutoIt like GUI automation tool for JAVA based applications?
...
The error is this:
The method add(String, int) in the type DataNode is not applicable for the arguments (String, String)
However, in the DataNode class, I have a number of overloaded add() methods, including one that takes a String and an int and one that takes two Strings. It appears that Eclipse isn't "seeing" the right add() met...
May be I am getting old, but I can't find it...
...
no ':' in url exception am getting that exception when am trying to execute this fragment of code...
FileConnection conn;
try{
conn =(FileConnection)Connector.open("/NewFile.xml");
if(!conn.exists())
conn.create();
_screen.add(new RichTextField("Connection Established..."));
_screen.add(new SeparatorField());
}...
Hello;
When my program runs, following error was taken:
Excepiton in theard "AWT -EventQueue -1" java.lang.UnsatisfiedLinkError: program.dll: Not enough storage is avaliable to process this command
[java] at java.lang.ClassLoader$NativeLibrary.load<Native Method>
[java] at java.lang.ClassLoader.loadLibrary0<ClassLoader.java:1751>
[jav...
Is there any java utility to convert string to hex value (integer) ?
...
Hello!
Using reflection on Java classes to access all field, methods, and so on:
Is there a standardized order of these elements (which is specified in some standard)?
Of course, I could check it empirically, but I need to know if it's always
the same.
EDIT:
I waited for the question: What I need the order for ;)
Long story short: I h...
Hi.
In many programming languages something like this is possible for prepared statements:
PreparedStatement statement = connection.prepareStatement(
"SELECT id FROM Company WHERE name LIKE ${name}");
statement.setString("name", "IBM");
But not with java.sql.PreparedStatement. In Java one has to use parameter indices:
PreparedSt...
I have a Java web application running in JBOSS with Tomcat with two web applications (contexts) running on it.
A button press on one of the applications opens runs a javascript command to open a new window with a page from the other.
The problem I seem to be having is that this raises a security alert in IE. with the following message:...
How can I assign 2 bytes to a variable in Java? I know I can do this:
byte val = 2; // this is one byte with 0000 0010
But I need to assign 2 bytes to val. How can I do this?
...
I need to run through a List in reverse order using Java.
So where this does it forwards:
for(String string: stringList){
//...do something
}
Is there some way to iterate the stringList in reverse order using the for each syntax?
For clarity: I know how to iterate a list in reverse order but would like to know (for curiosity's sake...
Do you know of a popular library (apache collections, google collections, etc...) which has a reliable Java implementation for a Min-Max heap?
I.e. a heap which allows to peek at its minimum and maximum value in O(1) and to remove at O(logn).
I did a quick search and couldn't find one. Anyone know better?
...