Penguin
Note: You are viewing an old revision of this page. View the current version.

Notes for Java / javac users.

(I use Java as a better C++ and don't use any of the awt/swing stuff, so I can't help there, sorry---StuartYeates)

Makefile rules

make(1) and Java don't play very well together, because unless you're careful you end up starting a new VirtualMachine for every file you want to compile (see the 'classes' target below for a complete hack). Remember that tabs and spaces get confused when cutting and pasting (see MakeFile).

JAVAC=javac JAVACOPTIONS= -g:none -O

  1. make a .class file from a .java file

%.class: %.java

$(JAVAC) $(JAVACOPTIONS) $<

  1. JAVACC stuff
  2. name/location of javacc executable

JAVACC=/home/say1/bin/javacc

  1. javacc options

JAVACCOPTIONS=-SANITY_CHECK=true -FORCE_LA_CHECK=true -DEBUG_PARSER=true -DEBUG_TOKEN_MANAGER=true

  1. build a java file from a JavaCC file

%.java: %.jj

$(JAVACC) $(JAVACCOPTIONS) $<

  1. a target that builds all the .java files in sight
classes

$(JAVAC) $(JAVACOPTIONS) .java /.java //.java

Tool support

  1. JavaDoc is your friend.
  2. Ant is your friend.
  3. JavaDeps is your friend.
  4. Eclipse IDE is your friend (superseeds JavaDeps and integrates Ant and JavaDoc)

Errors

Sometimes javac/Java complains that it can't find files which are plainly there or complains that they're in the wrong place. This is almost always a classpath or a package interaction problem. If the file is not in a package and is in the current directory:

  1. Check that the current directory is in the classpath
  2. Check whether you need to specific !ClassName? or !ClassName?.java
  3. Check spelling. Spelling matters.

If the file is in a package:

  1. Check the above points
  2. Check that the the file is in "/some/path/to/a/dircetory/some/package/heirarchy/!ClassName?.java" and is called "!ClassName?" and in "/some/package/heirarchy/" package
  3. Check that "/some/path/to/a/dircetory/" is in the the classpath
  4. Check that the current directory is not in the classpath
  5. Check the package name again

UserSubmittedNotes