How do you create a REST client for Java?

This is an old question (2008) so there are many more options now than there were then: Apache CXF has three different REST Client options Jersey (mentioned above). Spring RestTemplate superceded by Spring WebClient Commons HTTP Client build your own for older Java projects. UPDATES (projects still active in 2020): Apache HTTP Components (4.2) Fluent … Read more

Align printf output in Java

You can try the below example. Do use ‘-‘ before the width to ensure left indentation. By default they will be right indented; which may not suit your purpose. Format String Syntax: http://docs.oracle.com/javase/7/docs/api/java/util/Formatter.html#syntax Formatting Numeric Print Output: https://docs.oracle.com/javase/tutorial/java/data/numberformat.html PS: This could go as a comment to DwB’s answer, but i still don’t have permissions to … Read more

Creating a Calendar using javafx

I am a little stumped on how to get started on this project I have in front of me. I simply need to create a calendar on a javafx stage for the current date with two simple next / prior buttons to go between months. So far I have just created the minimum, a blank … Read more

Failed to install android-sdk: “java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema”

I had a similar problem this morning (trying to build for Android using Unity3D). I ended up uninstalling JDK9 and installing Java SE Development Kit 8u144. Hope this helps. brew cask uninstall java # uninstall java9 brew tap homebrew/cask-versions brew cask install java8 # install java8 touch ~/.android/repositories.cfg # without this file, error will occur … Read more

the getSource() and getActionCommand()

Assuming you are talking about the ActionEvent class, then there is a big difference between the two methods. getActionCommand() gives you a String representing the action command. The value is component specific; for a JButton you have the option to set the value with setActionCommand(String command) but for a JTextField if you don’t set this, … Read more

Long cannot be dereferenced

System.currentTimeMillis() returns a primitive long not a object Long. So you cannot invoke the longValue() method or any method on it as primitive cannot be the object of method invocations. Besides, it is useless to invoke longValue() as System.currentTimeMillis() returns already a long value. This is better : But in fact this condition : if(System.currentTimeMillis()==finish) … Read more

setMnemonic() and call a method by pressing the key

It’s worth reading here about Oracle Tutorial – Enabling Keyboard Operation where it is explained in details along with sample. Read more about on Oracle Tutorial – How to Use Key Bindings Some example directly from the above tutorial: Read more here Oracle Tutorial – How to Use Buttons, Check Boxes, and Radio Buttons Sample … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)