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 …
Tag: java
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… J…
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 doi…
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 table…
Weblogic 10.3 managed server shared memory object(s)
We are using Oracle Weblogic 10.3 as our application server. We have multiple modules that need to access an Object (contains some HashMaps) that is common for the managed server. This object will be populated via some other process on a daily basis. We do not want to have copies of this in each application, …
Parsing command-line arguments from a STRING in Clojure
I’m in a situation where I need to parse arguments from a string in the same way that they would be parsed if provided on the command-line to a Java/Clojure application. For example, I need to turn “foo “bar baz” ‘fooy barish’ foo” into (“foo” “bar b…
Spring: Using builder pattern to create a bean
I use ektorp to connect to CouchDB. The way to build an ektorp HttpClient instance is to use builder pattern: I am relatively new to Spring. Please advice me on how I can configure an HttpClient in my context to create it via the Builder. One way to do this is with @Configuration. Are any other options? Answe…
Performance in Java through code? [closed]
First of all I should mention that I’m aware of the fact that performance optimizations can be very project specific. I’m mostly not facing these special issues right now. I’m facing a bunch of …
I don’t understand the purpose of the src folder and separate packages
I’ve been using Eclipse only for Python over the last few months, and I’d like to start using it for Java. However, according to the tutorials I’ve looked at, the proper way to organize your Java project is to create a package in the source folder named, for example, com.project, and have al…