Posts

Showing posts from January, 2014

Themes for NetBeans

I have no idea how long this site has been around or how I missed it until very recently but I am glad I found it.  If you like NetBeans but would like to change the colors to match another favorite IDE or editor, there's a chance someone has already done it.  Check it out here

Happy editing,
Carl

JNLP: note to self

Java security was a hot topic in 2013 and I think it will continue to get some attention as tooling catches up to the newer requirements.  Signing the JNLP for Java Web Start programs is now required.

The Java Web Start maven plugin does not yet sign the JNLP file but there is an outstanding issue which I imagine will be resolved before too much longer.

In the meantime, this blog entry and this stackoverflow question and answer may be all you need to get your JNLP signed correctly.

The way I read it, you have two choices.

First you can create a template file which should be named APPLICATION_TEMPLATE.JNLP in src/main/resources/JNLP-INF and wildcards are permitted.  This is nice if you have the need to deploy your application from more than one server.

The second method involves creating a file named APPLICATION.JNLP also in the src/main/resources/JNLP-INF folder.  This file must match the application's jnlp file exactly.

Don't forget to modify your pom.xml file to include the …

Glassfish JNDI settings

Image
Recently we had the need to add some configurable settings (such as user credentials) in a Java EE 7 application running on Glassfish 4.0.
An example method to read the values might look like this:
    private String getUserProperty(String property) {
        String result = "";         Properties properties;         try {             InitialContext context = new InitialContext();             properties = (Properties) context.lookup("jndi/userinfo");             result = properties.getProperty(property);             context.close();         } catch (NamingException e) {         }         return result;     }

Setting the values via the Glassfish console is achieved via Resources -> JNDI -> Custom Resources.  Then clicking the New button will allow the new JNDI resource to be added.  Here we are using a java.util.Properties type so that we can add name/value pairs as needed below.



Then, for example, to get the username, we might do this:
String username = getUserProperty(&…

NetBeans 7.4 recent projects

Image
Recently I had the need to remove one project from my recent projects list in NetBeans.  The problem was I had opened a very large project which was causing the   
I found a few references to where one might find the file which contains the recent project list for older versions of NetBeans but they seemed to be a little dated.  
The file I wanted to find and edit is called projectui.properties
I happen to be on a Mac so that file could be found here:
~//Library/Application Support/NetBeans/7.4/config/Preferences/org/netbeans/modules
I opened the file with a text editor and looked for the project name in the openProjectsDisplayNames entries.  Each of the entries include a dot followed by a number at the end to make them unique.  Once I found it, I noted the number and deleted that line.  


Next I removed the corresponding entries in the openProjectsIcons and openProjectsURLs sections as well.
I have a couple of brute-force suggestions to remove the entire config directory structure (wh…

LibreOffice

I was recently asked about Mac/OS X software which can read and write WordPerfect format files.  As a not-so-regular but long-time OpenOffice user, the OpenOffice/LibreOffice debacle immediately came to mind.  There were numerous articles and blogposts written about the situation including a good bit of FUD.  The net effect on me is that I don't immediately know which one to recommend, assuming such a solution is otherwise in the best interest of the user.

Ultimately I tested LibreOffice 4.1.4 on a couple of handy WP files I had handy and it worked well enough for my own needs.  [The latest version of OpenOffice I had installed would not read WordPerfect files but I believe I have used a filter to do so in the past.]

The trick, however, seemed to be actually downloading a current copy from the LibreOffice site.  Perhaps I caught it at a bad time, but I had to try three mirror sites before I could get anything close to a reasonable download speed or worse a file which downloaded (t…

Complex JAX-RS

Working with JAX-RS to create a REST web service, I recently had the need to accept a List of a complex type as a parameter.  I was not able to find a complete example but I did read some Jersey documentation which I had not looked at in quite some time.  I read the Jersey Parameter Annotations section.

The issue I was running into was the lack of a constructor for the complex type I wanted to pass in a list as a parameter to a REST web service method.  The documentation made me realize that I did not have a constructor which accepted a single String parameter from which an instance could be properly created.

I also had some trouble with JSON marshalling/unmarshalling.  This may be a topic for another time but for now I solved it using the ObjectMapper from Jackson.

Ultimately I put a trivial demo app together which is available here.  The application was created using NetBeans 7.4 as a maven web app to run on Glassfish 4.0 for convenience.

I hope this is of help to someone.

Happy cod…