FreeBSD

FreeBSD for Writing Java

Rik Scarborough Development Technologies, Groovy, Java Leave a Comment

This one is just for fun. I’ve been using FreeBSD off and on since the late 90’s when a good friend, who has since passed, introduced me to the operating system.

Recently, for personal reasons, I’ve decided to move away from the big IT providers and install FreeBSD on my primary desktop for personal use. Just so it’s clear, I still use the operating system my client uses for work, but for my own personal desktop and coding projects, I’ve decided to once again install and run FreeBSD.

This post is not a tutorial, but let’s take some time to look at using this “Unix-like” operating system for real-world situations, such as developing Java applications for fun and profit.

FreeBSD on the Desktop

FreeBSD is used most often as a server operating system. A basic install will take you straight to a text base log in. You will have to install a graphic interface system yourself.

So, I guess I’ll take a moment and throw out a warning. If you are not comfortable with the command line, researching and installing the software you need, and updating configuration files after searching the web for solutions, FreeBSD may not be something you will enjoy. Any of the Linux distributions may be a more comfortable place to start.

Once installed, FreeBSD has two ways to install software. The Ports and the Package systems.

The Ports system is a repository of applications that can be installed from the source code and any patches needed to run the application under FreeBSD. You simply find the directory for that application and run make install

Yes, you are compiling the application for running on your machine. One benefit of this is you can turn on or off compiler flags to make the application more suitable for your environment, which can be a very powerful feature. The drawback is, well, you’re compiling the code. I ran make install on something this summer, I think it was the JDK, and it took half a day. Now, I will admit that the computer I am using is not the most up-to-date or powerful, though. It’s actually a retired system from a local library my wife works at.

The other install system is the Package system. Some very helpful and wonderful people have been compiling the Ports tree and putting the applications online for you. You just have to use the Package system, pkg on the command line, to install them.

A full overview of both systems can be found in the FreeBSD handbook.

To be completely honest, I prefer the Ports system. There is just something about compiling all the applications myself. But I don’t always have that kind of time, so I’m using the Package system. I tried for a while to use a combination of both, but that way madness lies.

Why?

I can tell there are some out there that will say, “Rik, that sounds terrible. Why would I run this?” Well, I want to highlight a couple of reasons, among a large list.

First, FreeBSD is rock solid. Unless you mess up the configuration terribly, which I have done, it runs well even on older computers. Second, and probably the most important to me, you get the satisfaction of running an operating system that has its ancestry in Unix, is not controlled by the big IT companies, and will make you feel like a Unix guru. You may even find yourself wanting to grow a beard.

For legal reasons, I have to disclose that the connection I just made between FreeBSD and Unix is my opinion. Because of lawyers and copyright law, it cannot truly be called a UNIX (yes there is a reason for the different cases in spelling Unix/UNIX; again copyright law). So, you will often see it described as a Unix-like operating system. In my opinion, it is a Unix operating system, and I have a beard to prove it; here’s a nickel.

Wikipedia has a page on the History of Unix that contains the different versions of BSD and FreeBSD and shows where they come from. As an aside, Dennis Ritchie Day is coming up on October 30th. I hope you have plans to celebrate. Also, celebrate Ken Thompson’s birthday on February 4th. These should be Federal holidays.

Java Programming

Ok, you’ve read this far, and I haven’t talked much about Java programming. Other than email and web surfing, two of the main things I use a computer for are writing and Java programming.

A quick aside, I am writing this blog post, several novellas, and other documents on FreeBSD using Vim and Markdown. I’ll upload this file to Google Docs for the final formatting.

For Java development, I am currently using OpenJDK 18.0.2. To get there, I had to tell FreeBSD to use the most current versions of the operating system and Ports, instead of the quarterly. Instructions can be found here. Then I used the pkg system to first search for the latest version and installed it on my system.

If you take a look around the system, which I highly encourage, you will see that FreeBSD has actually installed a wrapper around Java instead of putting the Java executable on the path. Looking at the wrapper, it appears that you should be able to switch between versions of Java installed on the system. I seem to remember that was something I had used in past versions of FreeBSD. At the time of this writing, however, I have not had any success in making it work. If it becomes something I need, I will look into it.

Now that I have Java installed, I could do all my coding in Vim and run Maven or Gradle from the command line. But this is 2022, so let’s look at IDEs.

My preferred IDE is Netbeans. I did a Package search on Netbeans, and it returns version netbeans-12.6. Uh oh. The current release of Netbeans is 15. So, instead of using the Package system, I downloaded the executable from https://netbeans.apache.org/, updated any configuration I need to, and added it to Gnome, my desktop environment.

Ok, so I have Java and an IDE. If you go back and look at the list of my other posts, you’ll quickly figure out I have a real love of the Groovy language. It is my scripting go-to for anything beyond shell scripting. Also my main squeeze for anything to do with JSON parsing or quick database access and data formatting. I just love it.

So, again back to Package search. Oh no, groovy-2.4.21. Groovy is at 4.0.5. So instead, I used SDKMAN (instructions here), and I got the latest version of Groovy, Gradle, and many other tools.

Because of the way SDKMAN works, I am forced to run Bash as my shell. I usually use CSH. But this does give me some separation from normal operations and development. All I have to do is type bash from a terminal, and I’m off.

My microservice framework of choice is Micronaut. Unfortunately, it doesn’t appear in the Package or Ports system and the version on SDKMAN is way behind on FreeBSD. It is up to date on other systems, so I surmise that the developers no longer build a version for FreeBSD.

I could, in my copious amounts of spare time, find the source code, patch it, build a port, and upload it to the FreeBSD system. But, there is also Micronaut Launch, which will build projects as well.

How I Use It

For my own personal use, I have developed several microservices to track my projects, tasks, time on each task, and reports for that data. The services are written in both Java and Groovy using the Micronaut framework with a MySQL database.

To interface with the services, I have written Groovy scripts that ask for data, format it into the proper JSON format, and send it to the services. For my own personal use, this works really well.

Conclusion

So, there I am. Java programming on a free, open-source, not-IT-oligarchy-controlled operating system and enjoying life.

If you are interested in learning more about FreeBSD, the website is the place to start. The Handbook will get you on the road and is probably one of the best examples of software documentation around.

As always, thanks for reading. I hope you found this post helpful or at least interesting. If you have questions or anything to add, drop a comment below!

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments