Temperature sensor with Java API
Depending on the requirements of your project and your skills there are some possibilities.


small microcontroller: gives you much control over what you do. you could for example push the data via a bluetooth module or usart/rs232 (with an usb-adapter if there is no rs232 port on your pc available). This option gives you also the ability to extend your project e.g. add more sensors.
a purchased sensor: there are also a few sensors available which can be connected to your pc e.g rs232/bluetooth/wifi


I would personally recommend rs232 or bluetooth as interface. rs232 can easily interfaced via jssc and there are cheap usb-rs232-adapters if your pc doesn't has one. if you choose bluetooth you could also write an app for smartphone users and other devices that support bluetooth. again it depends on the requirements of your project

edit: oracle just tweeted this article on the internet about interfacing with a temperature probe on raspberry pi