Java was designed by Sun Microsystems in the early 1990s to solve the problem of connecting many household machines together. This project failed because no one wanted to use it.
Then it was redesigned to work with cable TV. This project also failed because the cable companies decided to choose a competing system.
When the World Wide Web became popular in 1994, Sun realized that Java was the perfect programming language for the Web. Early in 1996 (late 1995?) they released Java (previously named Oak) and it was an instant success! It was a success, not because of marketing, but because there was a great need for a language with its characteristics.
Java 1.0 was the first version. Java 1.1 added important changes to user interface management, and many important new classes were added (JDBC, JavaBeans, ...). Java 2 was released at the end of 1998 with important additions to many different parts of Java, but especially with an improved graphical user interface, and many additional packages.