Working with OSGi and Java 9 Modules

Eric J. Bruno - April 2018
As many developers have learned, code modularity is more than just deining Java packages. It’s about specifying precisely which code is imported, which is shared publicly, and which is to be kept hidden. Proper modules also deine understandable contracts that give insight into how shared code will behave and interact. In this article, I’ll compare OSGi and Java 9 modular- ity, enumerate the strengths of each, and conclude with an example of how to use them together.

Read more...


TableListJS, Part 3: Inline Cell Editing and Database Connectivity

Eric J. Bruno - December 2017
In earlier posts, A Scrollable, Selectable HTML Table with JavaScript and CSS, and Adding Searching to the TableListJS HTML5 Component, I introduced an attractive HTML5 list component that uses CSS and JavaScript to create a customized, scrollable and selectable multi-column list (see Figure 1 below for an overview). In the second article, I added searching and filtering to the list to help find entries that match text entered—something particularly useful when scrolling through a list with many entries.

Read more...


TableListJS, Part 2: Adding Dynamic Filtering and Searching

Eric J. Bruno - November 2017
In a the article, I introduced a scrollable HTML multi-column table with selectable rows. In effect, the HTML table becomes a scrollable, multi-column list that you can use in forms where the user can make a selection. In this blog, we’ll add a search box to provide searching and filtering to the list to quickly find entries without scrolling and hunting.

Read more...


TableListJS, Part 1: A Scrollable, Selectable HTML Table with JavaScript and CSS

Eric J. Bruno - October 2017
We’ve all seen what a standard–and boring–HTML table looks like (see Figure 1). Sure, you can adjust the border size and style, and even use cascading style sheets (CSS) to spiff it up, but its utility is limited. For a web application I recently built, I needed a multi-column scrollable list, within which I could select an entry as part of an input form. I knew a basic HTML table wouldn’t fit the bill, so I changed it.

Read more...


How to Fix java.lang.NoSuchField

Eric J. Bruno - September 2017
Recently, after part of my hard drive crashed and I restored my Java development environment, I had trouble debugging one of my projects. This particular project was large, spread across multiple JAR files, and everything compiled just fine. However, when I went to run or debug it within my IDE, I consistently got a java.lang.NoSuchField Exception for a class member variable that was certainly there. When I ran the code from the command line via a script, it ran fine. I was perplexed.

Read more...


Calling Java Code from C/C++ Transparently

Eric J. Bruno - August 2017
I recently needed to create a C/C++ API for some existing Java code. The first thing that came to mind was to use the Java Native Interface (JNI). However, that can get ugly, mainly because JNI was designed to do the reverse (call C code from Java) and because it adds additional compilation steps. For example, you need to generate the JNI layer using the JDK’s javah tool, implement and compile the native C/C++ side of things, and then keep it all in sync as the Java code changes. Fortunately, there is an alternative: Java Native Access.

Read more...


Modularization Isn’t Just About Code

Eric J. Bruno - May 2017
Breaking a large project into more maintainable modules is more than splitting code across files. It involves componentization, distribution, developer considerations, ease of debugging, the effectiveness of testing, performance concerns, scripts, tools, and more. Then, after all that, you can consider the structure of the code itself. Let’s take a look at the forces you need to consider when modularizing your system.

Let’s begin with an important point in large-scale software development: good object-oriented design doesn’t equate to ideal code modularization. In a nutshell, this means it’s okay to break down a single C++ class into multiple source files. You can even break classes out across directories (or packages in other languages). In fact, this is one advantage of C++ over Java; it allows you to have different logical and physical class representations when it comes to the filesystem. Let’s look at some strategies to achieve this.

Read more...


Using HTML5 Server Sent Events (SSE)

Eric J. Bruno - September 2016
You’ve probably heard of HTML5 WebSockets , which is a powerful method to support full duplex, reliable messaging over HTTP/S. But have you explored HTML5’s Server-Sent Events (SSE), which is a simpler (albeit not as full featured) method of sending dynamic updates from an HTTP server to code in a browser? It works outside the browser as well, between applications written in any language. I like SSE because it doesn’t require a separate WebSockets server, it works over HTTP and HTTPS, it’s firewall friendly, and it’s simple. In this article, we’ll explore simple messaging over HTML5 SSE using a Java Servlet as the server and some JavaScript code in a web page as the client.

What Are Server-Sent Events?

You’ve probably heard of HTML5 WebSockets , which is a powerful method to support full duplex, reliable messaging over HTTP/S. But have you explored HTML5’s Server-Sent Events (SSE), which is a simpler (albeit not as full featured) method of sending dynamic updates from an HTTP server to code in a browser? It works outside the browser as well, between applications written in any language. I like SSE because it doesn’t require a separate WebSockets server, it works over HTTP and HTTPS, it’s firewall friendly, and it’s simple. In this article, we’ll explore simple messaging over HTML5 SSE using a Java Servlet as the server and some JavaScript code in a web page as the client.

Read more...