Help coderanch get a
new server
by contributing to the fundraiser

Jesper de Jong

Java Cowboy
+ Follow
since Aug 16, 2005
Jesper likes ...
Android Scala IntelliJ IDE Spring Java
Merit badge: grant badges
Forum Moderator
Jesper de Jong currently moderates these forums:
For More
The Netherlands
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jesper de Jong

I'm a member of Toastmasters as well, and I've done a few conference presentations.

There is a lot to learning how to do effective public speaking: from how you use your voice and your body, to how to use clear language and structuring your story with a clear opening, body and conclusion, and handling your nerves. It's really something that you have to practice a lot to get better at, and while you are practicing, you'll notice what your personal strong and weak points are, and which points you need to improve. Toastmasters is great for that - you get a lot of opportunities to practice, and your fellow club members will give you feedback which helps to improve yourself.
5 years ago
You have a string that contains this: "Thu May 24 19:00:00 COT 2018"

Now you are trying to convert this to a Date object, by calling parse() using a SimpleDateFormat object. For this to work, you must tell the SimpleDateFormat object what the date string looks like. In your code I see different templates: "dd/MM/yyyy", "hh:mm:ss a" in your Java code and "MM/dd/yyyy", "HH:mm:ss" in your JSF.

These format strings do not match the date string that you are trying to parse: "Thu May 24 19:00:00 COT 2018" does not have the format "dd/MM/yyyy", "hh:mm:ss a", "MM/dd/yyyy" or "HH:mm:ss". So, SimpleDateFormat is complaining that it does not understand how to parse the string "Thu May 24 19:00:00 COT 2018" using any of these formats.

Make sure the format string matches what is actually in the string you are trying to parse.
6 years ago
My brother and I got a Commodore 64 in December 1984. I quickly became interested in programming, first in BASIC and later in assembly language.

A few years later we got a Commodore Amiga 2000. I learned to program in C on the Amiga.

When I started studying at university, I got my first PC, which was a 386SX at 20 MHz with 1 MB (yes, MB, not GB) RAM and Windows 3.1. I learned programming in C++ on that.
6 years ago
Jon Skeet, the top question answerer on StackOverflow, recently wrote a blog post about StackOverflow culture.
6 years ago
With the way you describe things, it is very hard to understand what you mean. Please use clear and simple language, instead of abstract and general terms such as an "engine".

What are you trying to do, and what problem are you experiencing exactly?

Are you trying to send a JAR file as an attachment via e-mail, and is your mail server blocking it? If yes, then that's most likely for security reasons. Some mail servers do not allow you to send any kind of file that might contain executable code, to protect the receiver of the e-mail from running arbitrary code received from an e-mail (which is one way that computer viruses are distributed).

If this is your problem, then it doesn't have anything to do with Java or JAR files, and is simply a security feature of the e-mail system. One simple way to fix it could be to change the extension of the JAR file to something else (".xyz" for example) and then asking the receiver to rename it back to ".jar" before running it.
6 years ago
Nowadays, if you let your money sit on a savings account, it's only losing its value because the interest rate on savings accounts is almost zero.

There are many different ways to invest money in stocks. A relatively safe and easy way is to buy from a fund, which is a collection of stocks that are managed by whatever company or bank manages the fund. (I'm not sure if I'm using the right terms here, I'm not an expert either). About two years ago I did this and since the stock market has done very well in the past year, it's now up about 12% since when I bought it. My intention with this money is to keep it for the long term (I'm a freelancer and have to take care of my own pension, I don't have an employer to puts money in a pension fund for me).

If you really want to trade stocks of different companies directly, then yes, you would have to do a lot of research and learn how to follow the market and understand how to make decisions for buying and selling.

I bought Bitcoin for a few hundred euros a few weeks ago. Not as a serious investment, but just to see what would happen. Bitcoin went up more than 10x last year so it would be nice if my few hundred € would be worth a few thousand € in a year, and it's not so much money that if I'd lose it, I'd be seriously distressed. (The past week the Bitcoin fell quite a bit because different countries have announced they want to regulate cryptocoins more strictly, so right now I'm at a € 150 loss).
6 years ago
403 means Forbidden. Maybe the website requires you to log in before you are allowed to view the webpage. It's also possible that the website detects that you are not a regular browser (maybe by looking at the User-Agent header) and block you, because it doesn't want automated bots to be able to read the page.

If you need to log in, you'll have to do more in your program than just try to read from the page. It's most likely easier to program that using a library such as Apache HttpClient - Java's standard classes for reading webpages are quite underpowered and don't (easily) allow you to do things like logging in on a website.
6 years ago
If you want all the benefits of reactive, async / non-blocking, you'll need to make the whole stack async / non-blocking. JDBC is indeed inherently a blocking API, so you can't build a fully reactive / non-blocking app if you need to access the database through JDBC.

Oracle seems to be working on a new, async / non-blocking database API, which is (provisionally) called ADBA, but there's not a lot of information on it available yet. It will probably take a few years before it's available. Besides the API itself, database vendors will also need to implement non-blocking drivers.
6 years ago
It's a bit hard to say without seeing the whole project, but it's probably not the findBy() call that causes the record to be created in the database, but something else in your project.

Spring Boot automatically configures and does a lot of things automatically, which is on one hand good because it makes things easy and you don't have to write a lot of code to make things work, but on the other hand it makes it difficult to understand exactly what happens when you run the application. One of the things Spring Boot can do is automatically pick up certain files to populate the database when you start the application. For example, if you're using a regular relational database, you can put a file named data.sql in src/main/resources and it will automatically be executed (see chapter 78 of the Spring Boot manual). Maybe a similar mechanism exists for MongoDB and you have a file somewhere that gets loaded into the database at startup.

If you want to know exactly what's happening at startup, you can start your Spring Boot application with the --debug option on the command line, which will cause Spring Boot to write a detailed auto-configuration report to the console, which is useful for finding out what exactly is happening.
6 years ago
Yes, I think it was a hit on the web a few years ago and I've also played it for a while. Did you succeed in getting to 2048?

If you're tired of playing it yourself, you can try writing a program that plays it for you. Some people have used AI to write a program to play 2048.
6 years ago
You correctly understood what "static" means.

The of() method of class LocalDate is a factory method. It's a static method because you don't call it on an existing LocalDate object. Instead, it creates and returns a new LocalDate object.
6 years ago

Pete Letkeman wrote:I did recently see an article stating that extension methods get compiled into static methods when transformed into bytecode.
As a result the more extension methods you have, the more static methods you have, and people have different views on static methods.

If you write Java code with lots of static methods, then you're probably doing something wrong - you're most likely writing non-object-oriented, procedural code. But that is not really relevant for Kotlin extension methods - the fact that the Kotlin compiler happens to implement extension methods under the covers using static methods on the JVM doesn't make extension methods somehow bad.

Extension methods are a way to add methods to existing classes after the fact - or, that's what they seem to be at first sight.

In Java, people often create "utils" classes. Maybe you've written a StringUtils class yourself or used methods from such a class. Several well-known libraries have their own sets of "utils" classes, for example Apache Commons Lang and Spring both have their own StringUtils classes with utility methods for strings.

With Kotlin, instead of creating utility methods in a StringUtils class, you can create extension methods for class String instead. You can call these extension methods on String objects, and calling such a method looks exactly the same as calling any other method from class String:

Extension methods are not really dynamically added to a class - they are instead like any other external method, so they can for example not access the private variables of the class they are designed for.
6 years ago
I've been using Kotlin at work, so far only for a few little tools that I use myself.  I haven't yet used it extensively with Spring 5 yet.

Spring 5 does officially support Kotlin; the Kotlin support in Spring 5 mainly consists of two things: (1) making sure many things are annotated with @Nullable / @NonNull annotations so that it plays nice with Kotlin's null-safe type system, and (2) a number of extension methods to make working with Spring more convenient.

I've found, and I've seen from other projects / people using Kotlin, that extension methods are one of the most useful and powerful features that people pick up once they're going beyond the basics with Kotlin.

I like Kotlin a lot, and I hope I get the chance to use it a lot more in future projects.
6 years ago
It would be a lot easier if you would add an explanation to your code, besides only the title "How can I fix this code?".

What is the code supposed to do? What is the problem - do you get a compiler error, or an error when you try to run it? Or does it run, but produce output that is different from what you expected? If that's the case, then what exactly did you expect, what does it do in reality and how does that differ from what you expected?

Just by looking at it I can already see an error in the very first line: you are trying to import a class named Sec from the package java.util, but that package does not contain a class named Sec. What was your intention with that line? You're not using the class Sec in the code, so it seems redundant.

There are more errors. For example, String Map<String, String> in line 9 and nre HashMap in line 12, and i+=2> in line 16. You'll need to fix those syntax errors first.
6 years ago
The past week there was a lot of fuss about two security problems in Intel and other CPUs. Like with other security bugs that have happened before, these two have gotten their own catchy names and even a logo: Meltdown and Spectre.

Are you worried about these bugs, do you think they will affect you?

Here's a good video explanation of how these bugs exactly work:

6 years ago