Running an applet is a different animal than running a java application. Which are we talking about?
At either rate, compilation is the first step. To compile your source code (human readable file) into byte code, run it through the compiler (obviously). The command to do so is
If I were to look in that directory (dir \sandbox or explorer /e,C:\sandbox), I'd see at least two files (assuming the code was syntactically correct). My source code (WizBang.java) and the byte code (WizBang.class and any inner classes but since this is an intro course, we'll leave them be).
Now, I'm ready to run my code. If it's an application, I will invoke the java virtual machine (JVM) on it via the java command
The rules appear to have changed (or I was ignorant of them) but to get an applet to run, in my day (2000) you needed to provide an HTML wrapper for the applet call. Then either point your browser to the HTML file or call the appletviewer. Since answering other applet questions in this forum, I did some testing and at least for me, it seems the requirement of writing the wrapper has gone to the wayside if you run the applet via the appletviewer. Thus
Code: Select all
C:\sandbox>iexplore WizBang.html
or
C:\sandbox>appletviewer WizBang.html
or
C:\sandbox>appletviewer WizBang
all seemed to produce the same results on my machine. At least, I'm pretty sure they did. I can't find where I put the files and I'm too lazy/hate applets too much to recreate them.
All of the aforementioned code assumes the current directory (.) is in the classpath and that the Java binary tools directory and possibly Internet Explorer is in your executable search path.