Skip to content
Advertisement

Why do threads share the heap space?

Threads each have their own stack, but they share a common heap. Its clear to everyone that stack is for local/method variables & heap is for instance/class variables. What is the benefit of sharing heap among threads. There are several number of threads running simultaneously, so sharing memory can lead to issues such as concurrent modification, mutual exclusion etc overhead.

What version of javac built my jar?

How can I tell what version of the Java compiler was used to build a jar? I have a jar file, and it could have been built in any one of three JDKs. We need to know exactly which one, so we can certify compatibility. Is the compiler version embedded somewhere in the class files or jar? Answer You can’t

Write x509 certificate into PEM formatted string in java?

Is there some high level way to write an X509Certificate into a PEM formatted string? Currently I’m doing x509cert.encode() to write it into a DER formatted string, then base 64 encoding it and appending the header and footer to create a PEM string, but it seems bad. Especially since I have to throw in line breaks too. Answer This is

How to pass a text file as a argument?

Im trying to write a program to read a text file through args but when i run it, it always says the file can’t be found even though i placed it inside the same folder as the main.java that im running. Does anyone know the solution to my problem or a better way of reading a text file? Answer Do

Bringing unit testing to an existing project

I’m working on an existing Java EE project with various maven modules that are developed in Eclipse, bundled together and deployed on JBoss using Java 1.6. I have the opportunity to prepare any framework and document how unit testing should be brought to the project. Can you offer any advice on… JUnit is where I expect to start, is this

Change private static final field using Java reflection

I have a class with a private static final field that, unfortunately, I need to change it at run-time. Using reflection I get this error: java.lang.IllegalAccessException: Can not set static final boolean field Is there any way to change the value? Answer Assuming no SecurityManager is preventing you from doing this, you can use setAccessible to get around private and

Time within a particular time interval

i’m trying to solve a seemingly simple problem, but just can’t quite get my mind around it. i have two times startTime and stopTime, which can be considered to be in the format: hh:mm:ss [24hr format]…

How to join tables using sqlite in android

I am trying to find out how to do a simple table join on my two tables using a sqlite database in an android application. Is the simplest way to use CursorJoiner or is there any easier way? Answer In the implementation of SQLiteDatabase and SQLiteQueryBuilder you will see that it is possible to pass the tables you want to

Advertisement