java


macos - Where is Java Installed on Mac OS X?

Use /usr/libexec/java_home -v 1.8 command on a terminal shell to figure out where is your Java 1.8 home directory If you just want to find out the home directory of your most recent version of Java,... Read More


Parse any date in Java

Your best bet is really asking help to regex to match the date format pattern and/or to do brute forcing. Several years ago I wrote a little silly DateUtil class which did the job. Here's an extract... Read More


How do Java Interfaces simulate multiple inheritance?

Suppose you have 2 kinds of things in your domain : Trucks and Kitchens Trucks have a driveTo() method and Kitchens a cook() method. Now suppose Pauli decides to sell pizzas from the back of a delive... Read More


multithreading - Java thread executing remainder operation in a loop blocks all other threads

After all the explanations here (thanks to Peter Lawrey) we found that the main source of this pause is that safepoint inside the loop is reached rather rarely so it takes a long time to stop all thr... Read More


java - Using Selenium Web Driver to retrieve value of a HTML input

Try element.getAttribute("value") The text property is for text within the tags of an element. For input elements, the displayed text is not wrapped by the <input> tag, instead it's inside the value... Read More


Compiling Java 7 code via Maven

Check the mvn script in your maven installation to see how it's building the command. Perhaps you or someone else has hard-coded a JAVA_HOME in there and forgotten about it.... Read More


java - Is id = 1 - id atomic?

Am I wrong? Nope, you're absolutely right - as is your example timeline. In addition to it not being atomic, it's not guaranteed that the write to id will be picked up by the other thread anyway, g... Read More


java - Viewing complete strings while debugging in Eclipse

In the Variables view you can right click on Details pane (the section where the string content is displayed) and select "Max Length..." popup menu. The same length applies to expression inspector po... Read More


multithreading - How to make a Java thread wait for another thread's output?

Use a CountDownLatch with a counter of 1. CountDownLatch latch = new CountDownLatch(1); Now in the app thread do- latch.await(); In the db thread, after you are done, do - latch.countDown();... Read More


caching - Java time-based map/cache with expiring keys

Yes. Google Collections, or Guava as it is named now has something called MapMaker which can do exactly that. ConcurrentMap<Key, Graph> graphs = new MapMaker() .concurrencyLevel(4) .softKeys()... Read More