Rev | Author | # | Line |
---|---|---|---|
5 | StuartYeates | 1 | Notes for [Java] / [javac] users. |
2 | |||
10 | AristotlePagaltzis | 3 | (''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) |
5 | StuartYeates | 4 | |
10 | AristotlePagaltzis | 5 | !!! MakeFile rules |
5 | StuartYeates | 6 | |
7 | 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). | ||
8 | |||
10 | AristotlePagaltzis | 9 | <verbatim> |
5 | StuartYeates | 10 | JAVAC=javac |
11 | JAVACOPTIONS= -g:none -O | ||
12 | |||
13 | #make a .class file from a .java file | ||
14 | %.class: %.java | ||
10 | AristotlePagaltzis | 15 | $(JAVAC) $(JAVACOPTIONS) $< |
5 | StuartYeates | 16 | |
17 | # JAVACC stuff | ||
18 | |||
19 | #name/location of javacc executable | ||
20 | JAVACC=/home/say1/bin/javacc | ||
21 | |||
22 | #javacc options | ||
23 | JAVACCOPTIONS=-SANITY_CHECK=true -FORCE_LA_CHECK=true -DEBUG_PARSER=true -DEBUG_TOKEN_MANAGER=true | ||
24 | |||
25 | # build a java file from a JavaCC file | ||
26 | %.java: %.jj | ||
10 | AristotlePagaltzis | 27 | $(JAVACC) $(JAVACCOPTIONS) $< |
5 | StuartYeates | 28 | |
29 | # a target that builds all the .java files in sight | ||
30 | classes: | ||
10 | AristotlePagaltzis | 31 | $(JAVAC) $(JAVACOPTIONS) *.java */*.java */*/*.java |
32 | </verbatim> | ||
5 | StuartYeates | 33 | |
34 | !!! Tool support | ||
35 | |||
36 | # JavaDoc is your friend. | ||
37 | # [Ant] is your friend. | ||
38 | # JavaDeps is your friend. | ||
12 | LawrenceDoliveiro | 39 | # [Eclipse] [IDE] is your friend (supersedes JavaDeps and integrates [Ant] and JavaDoc) |
5 | StuartYeates | 40 | |
10 | AristotlePagaltzis | 41 | !!! Errors |
5 | StuartYeates | 42 | |
43 | 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: | ||
10 | AristotlePagaltzis | 44 | |
45 | # Check that the current directory is in the classpath | ||
46 | # Check whether you need to specific ~ClassName or <tt>~ClassName.java</tt> | ||
47 | # Check spelling. Spelling matters. | ||
5 | StuartYeates | 48 | |
49 | If the file is in a package: | ||
50 | |||
10 | AristotlePagaltzis | 51 | # Check the above points |
52 | # 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 | ||
53 | # Check that <tt>/some/path/to/a/dircetory/</tt> is in the the classpath | ||
54 | # Check that the current directory is not in the classpath | ||
55 | # Check the package name again | ||
9 | BenStaz | 56 | |
10 | AristotlePagaltzis | 57 | !! The public type ~SomeClassName must be defined in its own file |
58 | |||
59 | Check to make sure that the filename of the .java file has the same name as the class inside the file. | ||
9 | BenStaz | 60 | |
10 | AristotlePagaltzis | 61 | !!! How do I run a jar file? |
9 | BenStaz | 62 | |
10 | AristotlePagaltzis | 63 | 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]:'''' |
9 | BenStaz | 64 | |
10 | AristotlePagaltzis | 65 | <verbatim> |
66 | java -jar $JAR_FILE | ||
67 | </verbatim> | ||
5 | StuartYeates | 68 | |
69 | ---- | ||
70 | UserSubmittedNotes |
lib/blame.php:177: Warning: Invalid argument supplied for foreach() (...repeated 2 times)