Check out part one here if you haven't completed it yet.
Java Code Challenge is a regular segment taking the best challenge from Reddit's dailyprogrammer. Things are a little different here as we're focused on Java. A working solution is not enough; we're looking for the cleanest Java code with tests. 3rd party libraries are welcome but if you can do it without it will be easier for others to comprehend.
I haven’t publish any book reviews lately. It does not mean I am not reading books anymore. I just didn’t feel that some of the books I read recently requires my recommendation, or I didn’t have any thoughts that I needed necessary to share right now.
I have added a few books to my favorite books list though. Check them out!
If you have been with us since the beginning, you know we are mimicking the journey of some "useful" (let's pretend, shall we) piece of software that began life as just some code.
It is turning into something more serious, and we now have somewhat of a resuable component.
Thread dumps are vital artifacts to diagnose CPU spikes, deadlocks, memory problems, unresponsive applications, poor response times, and other system problems. There are great online thread dump analysis tools such as http://fastthread.io/ that can analyze and spot problems. But to those tools you need provide proper thread dumps as input. Thus in this article, I have documented 7 different options to capture thread dumps.1. jstack
‘jstack’ is an effective command line tool to capture thread dumps. The jstack tool is shipped in JDK_HOME\bin folder. Here is the command that you need to issue to capture thread dump:
Recorded at SpringOne Platform 2016.
Speaker: Jüergen Hoeller
From the dexecutor website:
Executing dependent/independent tasks in a reliable way is made so easy that even grandma can do it.
In an announcement on the NetBeans homepage, Oracle has proposed contributing the NetBeans IDE to the Apache Incubator to be known as Apache NetBeans. NetBeans was acquired by Sun Microsystems and made open source over fifteen years ago, and the announcement claims 1.5 million active users.
Even though it was already an open source project, the move should allow for increased contribution and collaboration with outside developers to improve the product, while taking Oracle off the hook for any potential neglect. Part of the NetBeans.org statement reads:
Functional composition is an extremely useful tool for creating modular, testable programs. One of the most natural applications of functional composition that I’ve found is creating a lightweight, composable HTTP request builder, and with that objective in focus, this post will equip you with the tools you need to simplify your HTTP clients.
In a microservice-based environment, distributed services need to communicate with each other over the network. Many times the protocol of choice is HTTP. What do you do when you need to expose an API for a given service? Create a client of course! Clients are great and should be used, but the issue with clients is that adding new endpoints or changing existing methods can be both tedious and error prone. It’s tough to remember exactly how to accomplish these tasks every time you need to hop into the client to make changes. Ever had to skim through a bunch of code just to remember how to add a new method to the client? Questions that frequently come up are:
When you search for some Maven artifact (Java library), you usually use one of two methods:
A short time back I also asked the Java community on Google+ which search engine they use. These were the answers (181 people voted). Later on you will see that mvnrepository.com currently prevails because it's easily searchable by Google, has existed for 10 long years, and does a pretty good job (at least for a basic dependency search in Central Repository):
Note: The instructions below are based on Windows environment, but are adaptable for Mac/Linux environments.Sublime Text 2Compile and Execute Java From Sublime Text 2:
Assuming JDK to be installed, otherise you need to download that first. You can download it from this link: JDK8
A singleton pattern is probably the simplest well-known design pattern, but still people often implement it incorrectly in Java. The main goal of the pattern is to ensure there is a single instance of a class that is globally accessible before it is first needed.
But wait, that could be accomplished just by a constant, right? Almost. But in reality, we often want to load the singleton lazily at the point we first need it, and we also want to ensure that it is not created multiple times in multi-threaded environments.
We are on our way to developing and exploring various technologies of web applications and web services, but we begin with a simple program that turns into a resuable component. Read the previous section here!
You can review all the code changes that we have created from previous articles, by going here: https://github.com/elicorrales/shape-calc-5/tree/master/shape-calc-p5