Differences between version 10 and previous revision of JavaNotes.
Other diffs: Previous Major Revision, Previous Author, or view the Annotated Edit History
Newer page: | version 10 | Last edited on Wednesday, May 2, 2007 9:37:57 am | by AristotlePagaltzis | Revert |
Older page: | version 9 | Last edited on Wednesday, May 2, 2007 8:56:36 am | by BenStaz | Revert |
@@ -1,18 +1,19 @@
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)
+(''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
+!!! 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).
+ <verbatim>
JAVAC=javac
JAVACOPTIONS= -g:none -O
#make a .class file from a .java file
%.class: %.java
-
$(JAVAC) $(JAVACOPTIONS) $<
+
$(JAVAC) $(JAVACOPTIONS) $<
# JAVACC stuff
#name/location of javacc executable
@@ -22,44 +23,48 @@
JAVACCOPTIONS=-SANITY_CHECK=true -FORCE_LA_CHECK=true -DEBUG_PARSER=true -DEBUG_TOKEN_MANAGER=true
# build a java file from a JavaCC file
%.java: %.jj
-
$(JAVACC) $(JAVACCOPTIONS) $<
+
$(JAVACC) $(JAVACCOPTIONS) $<
# a target that builds all the .java files in sight
classes:
-
$(JAVAC) $(JAVACOPTIONS) *.java */*.java */*/*.java
+
$(JAVAC) $(JAVACOPTIONS) *.java */*.java */*/*.java
+ </verbatim>
!!! Tool support
# JavaDoc is your friend.
# [Ant] is your friend.
# JavaDeps is your friend.
# [Eclipse] [IDE] is your friend (superseeds JavaDeps and integrates [Ant] and JavaDoc)
-!!!Errors
+!!! 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:
-#Check that the current directory is in the classpath
-#Check whether you need to specific !
ClassName or !
ClassName.java
-#Check spelling. Spelling matters.
+
+
# Check that the current directory is in the classpath
+# Check whether you need to specific ~
ClassName or <tt>~
ClassName.java</tt>
+# Check spelling. Spelling matters.
If the file is in a package:
-#Check the above points
-#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
-#Check that "/some/path/to/a/dircetory/" is in the the classpath
-#Check that the current directory is not in the classpath
-#Check the package name again
-!The public type
<name of class
> must be defined
in its own file
-Check to make sure
that the filename of
the .java file has
the same name as
the class inside
the file.
+# Check the above points
+# Check that the the file is in
<tt
>/some/path/to/a/dircetory/some/package/heirarchy/~ClassName.java</tt> and is called <tt>~ClassName</tt> and
in <tt>/some/package/heirarchy/</tt> package
+#
Check that <tt>/some/path/to/a/dircetory/</tt> is in
the the classpath
+# Check that
the current directory is not in
the classpath
+# Check
the package name again
-!!!How do I run a jar
file?
+!! The public type ~SomeClassName must be defined in its own
file
+
+Check to make sure that the filename of the .java file has the same name as the class inside the file.
-A JAR file (or Java Archive) is
a ZIP
file used to distribute a set of Java classes. It is used to store compiled Java classes and associated metadata that can constitute a program.
+!!! How do I run
a jar
file?
-To run a [
Java] application that
is inside
a .jar
file Simply type
:
+A JAR file (or
Java Archive)
is a zip
file used to distribute a set of compiled Java classes with some associated metadata. It might be just a library, but could also be an application; in that case, you have to run it via the [JVM]
:''''
-*
java -jar <jar
_file
>
+ <verbatim>
+
java -jar $JAR
_FILE
+ </verbatim
>
----
UserSubmittedNotes