The original source code is written as plain text files (ending in .java). This must be compiled to java bytecode class files (ending in .class). These class files are then interpreted by the JVM.
Note many class files may also be packaged together in a "java archive" (.jar) file, which is compressed like zip to make it easy to send across the web.
The class files are the same for any type of computer, but the java virtual machine (JVM) is different and must be set up locally, as it converts java bytecode to raw machine code, and interacts with the operating system.
The JVM may be built into a web browser for running applets. Internet Explorer and Netscape provide their own JVMs, which differ between versions and platforms. It's also possible to use a JVM without a web browser (e.g. Sun JRE).
In theory, this JVM arrangement means you can "write once run anywhere", yet the calculations run much faster than directly interpreted languages such as basic or javascript.
The JVM also incorporates security checks which restrict what an applet loaded across the web can do -for instance it can't load or save files locally, only on the server from which it came. This makes it "safe" for applications in web browsers. Also, java was designed to make it easy to communicate across the web, with many networking and "internationalisation" features.
The modular "object oriented" structure is good for making an interactive graphical-user interface where the flow may jump about, and where components may be reused in different ways. However it takes a while to learn to construct a basic framework, before you can develop anything interesting.