A Java dev journey to full-stack: first chapter

Victor Gil
4 min readJan 15, 2019

--

The Motivation
I am an experienced Java developer and unsurprisingly, I like Java. I know it is not perfect but it works just fine for me (I enjoy type-safety and I do not consider verbosity a disadvantage, quite the opposite). I also know that some people dislike Java, which is also fine.

But recently I decided to step out of my confort zone as developer, my goal isn’t to be one of the “cool kids” neither trying to monetize a new skill in the job market.
I have a quite practical motivation: I want to be able to build more (different) stuff. That’s exactly the same reason why I learnt Android development by myself a couple of years ago.

Web applications are ubiquitous, even more than native mobile apps, and thanks to cloud computing, one can easily and inexpensively release their idea/app to the World Wide Web.

I already did some Web development in the past, in the bad old days of JSP and JSF, but the process was slow and painful.

Nowadays the Web landscape has totally changed though, JavaScript is a mature language, it provides classes (well, not really, but bear with me) and a whole ecosystem which includes dependency injection, dependency resolution, a backend server (Node.js) and advanced IDEs.

The JavaScript Framework
So the first step was to decide what to use for frontend development, among the numerous options, there are two main ones (by popularity): React or Angular.

After some research it seemed that Angular was more suitable for devs coming from the Java world, mainly because of two reasons:

  • Typescript is more strongly typed than “naked” JavaScript, which makes it more similar to Java.
  • Angular is a framework (not a library like React) which means that it provides more guidance (it’s opinionated) and includes a comprehensive set of helper tools (e.g., a CLI).

Hence, I chose Angular and VSCode as my Integrated Development Environment.

The Proof Of Concept
After having decided with what I’d code, one more important question remained open: what to code.

All I knew is that I wanted to make a modern (albeit simple) single page Web site. And by modern I essentially mean asynchronous live data loading onto the UI without user interaction (i.e., server data push, no need to click the “refresh” button).

But what would be the source of the data? That’s when I decided to make things more interesting by throwing Android into the mix.

I decided that the application would push location updates from my phone to the backend running on AWS and then to the Web browser. All the data transfers would be in JSON format and secured by HTTPS (self-signed certificate).

And since I was already in ‘adventurous mode’, I decided to use Vert.x (a Java framework to build reactive applications) in the backend because it had been on my radar for a while already and it also provides good integration with JavaScript through its SockJS event bus bridge.

You can see how (version 1 of) the web application works in the following video:

The Code
After several weeks of after-work coding and dealing with three different Git repositories, three different IDEs (AndroidStudio, Eclipse and VSCode) and two programming languages (Java and Typescript), I am ready to share the code with anyone who would care to have a look at it:

mylocation-frontend
mylocation-backend
mylocation-android

And the first version (UPDATE: second version is already available) of the application is live at http://mylocation.devaction.net

Please note that you will get “your connection is not private” warning (or some other similar one depending on your browser of choice) when accessing it because of the self-signed certificate, but as long as you check that the SHA-256 fingerprint matches the following hexadecimal digits, you are safe: DA C1 F8 06 D2 4E 17 C9 C4 F4 D7 47 40 AF CD F1 22 00 36 3E 97 CB 41 C2 63 DD 28 1F A0 51 12 29

Also, I do not think the backend will be able to handle much load since it runs on the smallest type of Amazon Lightsail instances (just 512 MB memory and one core processor →UPDATE: VM upgraded to 1GB RAM) so if it is not able to keep up with the demand at least it would mean that this post has become somewhat popular :-)

I could write much more on related topics such as:
— How I combined Vert.x and Spring in the backend.
— The Android service which fetches the location provided by the GPS.
— Client-side certificate (in Android).
— The application configuration (loading, password encryption).
— RxJS.
— The Vert.x event bus SockJS bridge.
— The social implications of sharing my live location with potentially everybody (spoiler alert: I introduced a “masking” security mechanism in the Android code to keep the area where I live under the radar).

But I will leave that for future chapters of this journey since this learning exercise is far from over yet, stay tuned!
UPDATE: next episode.

Originally published at www.devaction.net.

--

--