> Programming > Java > Using jMusic on Windows 95/98 | |||||
Using jMusic on Windows 95/98This page assumes you have installed Java, the Java SDK (Software development kit) and jMusic. See the install instructions if required. DOS Prompt Java programming involves running programs from the command line, or
DOS prompt. Java runner and compiler The command line allows you to type commands, such as java and javac
(the Java compiler). C:> java C:> javac Changing directories If you do not get a usage error for javac then it may be best to navigate
to the javac directory and work from there. The command cd is an abbreviation of change directory. The DOS prompt will change to indicate your current directory location, It may read C:\jdk1.4\bin> but in this page I will always abbreviate it to C:> This is not a convenient way to get javac to to work. In the next section we'll create a new directory and work from in there. When we do so we can access the javac by explicitly using its full path name. C:> C:\jdk1.4\bin\javac Creating directories Assuming you have a jMusic directory already let's create a folder within that for our Java work. At the prompt type C:> mkdir C:\jMusic\JavaWork You can follow these changes to directories and files in a Windows Explorer window as you go along to keep a familiar eye on what we're doing here. Navigate to this new directory, we'll work from here. C:> cd C:\jMusic\JavaWork Editing files To proceed further we need a java file to work with. Java files are simple text files and DOS includes a suitable editor - called edit. To start the editor type C:> edit Type in this simple Java program.
Use the menu commands in edit to save the file to your work directory with the name Test.java, here is the directory path as a reminder - C:\jMusic\JavaWork\Test.java Use Windows Explorer to look inside the JavaWork folder to make sure the Test file is saved there. Exit from the editor. Compiling The javac command is used for compiling. It needs to know where the file is located, so we specify its classpath. A hint: You may often need to retype the same commands so there is a program that can recall previously typed commands using the up and down arrow keys. C:> doskey To compile type C:> C:\jdk1.4\bin\javac Test.java A file called Test.class should be created in the JavaWork directory. Running To run the class file use the java command with a class path and file name. Notice that when running you omit any suffix from the program name. C:> java -classpath "C:\jMusic\JavaWork" Test You should see the words Java Works appear at the command line. Adding jMusic Start edit, and open the file and change it to add these jMusic additions.
Save the file. Quit edit. Recompile the class (remember to use the up arrow to save typing). Rerun the program. A MIDI file with one note should be added to your JavaWork directory, and jMusic will print various messages to the command line as it proceeds. To compile or run you will need to set the classpath to jMusic. C:> C:\jdk1.3\bin\javac -classpath "C:\jMusic\lib\jmusic.jar" Test.java C:> java -classpath "C:\jMusic\JavaWork;C:\jMusic\lib\jmusic.jar" Test Exploring Now it's time for you to make changes to the program and to practice the edit, compile run cycle. |
|||||