The shortest way I can think of in Java is:
Optional.ofNullable(option.getOrElse(null))
@ RΓ©gisJean-Gilles actually suggested even shorter if you are writing a conversion in Scala:
Optional.ofNullable(option.orNull)
By the way, you should know that Scala does not support Java 8 until Scala 2.12, which has not yet been officially announced. Looking at the docs (which may change before release), there is no such conversion in JavaConversions .
source share