up previous next contents index
Next: Sending the class file Up: Writing your first Lejos Previous: Writing your first Lejos   Contents   Index

Compiling the HelloWorld program

Compiling the HelloWorld.java program is simple, but different than the normal Java environment. Instead of using the javac command to do the compiling, you'll want to use lejosc to compile your source file.

The first thing you'll want to do is to open up a DOS prompt, and CD to the directory where your HelloWorld.java file is located. Since my file is located in my c: \Temp directory, I'll open up a DOS window, run my lejos_setup.bat program, then enter:

cd c:\Temp

If you're new to DOS, you may want to enter the DIR command at that point to confirm that your file is in that directory, like this:

dir

Then you can confirm that your Java source code file is in the directory like this:

dir HelloWorld.java

Next, to compile the program, enter:

lejosc HelloWorld.java

If everything goes well, you won't see any output from the command, and this will compile into a HelloWorld.class file (which you can also check with the dir command). You can then download this class file to the RCX, as discussed in the next section.

If you run into errors, they can be caused by a variety of reasons, including:

  1. You may not have a Java JDK properly installed.
  2. Lejos may not be properly installed.
  3. Environment variables, including PATH, JAVA_HOME, LEJOS_HOME, RCXTTY, and CLASSPATH may not be set properly.
  4. Case-sensitive issues. Java is a case-sensitive language, so if you name a class HelloWorld, your class file better be named HelloWorld.java, and not something like helloworld.java, because that will not work on certain versions of Windows.
  5. Spelling issues. Again, if a class is named HelloWorld, your class file better not be named JelloWorld.java. At this point I'm starting to get into compiling/debugging issues, so I'll stop here for now.

Hopefully you will not encounter any of those problems, and you're ready to transmit your program to the brick.


up previous next contents index
Next: Sending the class file Up: Writing your first Lejos Previous: Writing your first Lejos   Contents   Index