Packages that are not included in the JDK (for example javax.websocket
) need to be downloaded and referred to with -cp
or the CLASSPATH
environment variable in order to be imported (otherwise you get the compilation error package X does not exist).
After compilation, when the .class files are obtained, is it possible to transfer these files to a computer that does not have the javax.websocket
package, and have the JVM on that computer run them, or is it necessary to have the package on both computers?
In other words: When you write import bar.foo;
, you are essentially writing "Every time you see foo
, go to this location and see what it is.". However, when you have compiled the source code, does the byte code still say "go to this location and see what it is", or has it already gone to the location and "imported" everything so that the location is no longer needed?