| CIT 594: Forté FAQ Dave Matuszek |
|
Win extra credit! If you are the first person to submit a problem and its correct solution, and I add it to this FAQ, you can win 5, 10, even 15 points! Entries will be judged on whether I think the solution is correct, is sufficiently non-obvious to be worth adding to this FAQ, and is explained clearly enough for me to understand. Good spelling and grammar are optional. |
Problems
java.lang.NoSuchMethodError:
main java.lang.NoSuchMethodError:
main error. cannot resolve symbol
errors for normal Java classes, like Button or Color.There is no installed server. The execution/debugging
is not allowed.Java causes invalid page fault in module
Kernel32.DLL - Windows 98Reformat Code command doesn't work.main
method?General information
Problems
There is a very bad interaction between Forté and Linux when you have exceeded your disk quota. Apparently, the system issues an error message, but Forté doesn't pass it along to you.
For now, the best temporary solution seems to be (1) keep backups, and
(2) don't run out of disk space. Remove your MP3s and other large but unnecessary
files (you can see the size of your files with the ls -l command).
Remove any core files. Then, log into eniac and run the command
raisequota. You can check your current disk usage with the
quota command.
I'm trying to find a better, more permanent solution.
java.lang.NoSuchMethodError:
main
Exception in thread "main"There are several reasons this might happen.
Any class may have a main method, and you can begin executing
your program at the main method of any class. Forté
tries to start executing your program at the main method
of the class that's showing in the Source Editor window.
If that class doesn't have a main method (or if the main
method doesn't have the signature public static void main(String args[])
), you will get this message.
It may help to look at the Explorer [Filesystems] window:
the Java files that have a main method are marked with a tiny green
triangle. However, selecting a file in this window does not
cause Forté to begin executing your program with that class.
.nbattrs and xxx.form
(where xxx is the name of one of your classes).
If you move or copy your files and don't include these two files, Forté
will give you this error. package
declaration to one or more of your Java files. If your main class
is named myClass, and the package statement reads package
upper.lower; then myClass.class must be in a directory
named lower which is inside a directory named upper.
To execute this program from the command line, navigate to the directory
containing the upper directory and issue the command
java upper/lower/myClass. set classpath=.
and try again.
java.lang.NoSuchMethodError:
main error.From Tsung-Fang Tu: Forté keeps track of whether you have an application or an applet, but (for some as yet unknown reason), sometimes it forgets. To tell it that your project is an applet:
Properties. The Properties window will pop
up.Execution tabbed pane on the buttom of the Properties
window.Debugger property to Applet Debugging.Executor property to Applet Execution.Applets must be run from an HTML file. By default, Forté gives your
HTML file the same name as your Java source file, but with the .html
extension instead of the .java extension. If you look
closely, you will see that the icons are different--the .html icon
has a tiny globe on it, while the .java file has some sort
of red blobby thing on it.
The Explorer [Filesystems] window lists all the directories and files that Forté can access. If you have older versions of your files somewhere in a mounted filesystem, Forté may well try to compile and use those files as well. If the old versions of the files are in the same directory, move them somewhere else; if they are in a different directory, unmount that directory.
Forté has a much nicer way of keeping track of old versions, called
CVS (Concurrent Versions System). CVS isn't just a Forté thing, it's
the most popular versioning system on Windows. CVS is moderately complex,
but (like any good tool) learning to use it is worth the effort.
The message you get is something like java.lang.NoClassDefFoundError:
myClass (wrong name: myFolder/myClass). Actually, this is telling
you that your package name doesn't agree with the name of the
directory your file is in. There are two possible solutions: (1) learn the
rules for package names; the rules are very simple, but in practice it isn't
always easy to get it right; or (2) just delete all the package declarations
and throw away the backup file (the one ending with a ~). If
you don't throw away the backup file, the package directive
seems to keep coming back--I don't know why. For an applet, you should also
correct the HTML file.
cannot resolve symbol errors for normal Java classes, like
Button or Color.You probably forgot to import the appropriate packages. Forté doesn't
import any packages; instead, it uses the fully-qualified names (java.whatever).
You can import the classes or packages yourself (import statements
go after the package statement, if there is one), or you can
use the fully-qualified names. Or both--it's legal to mix the two styles.
When you move from one tabbed pane to another in Forté's main window, various other windows open and close. The first thing to do is to check whether you have the right tabbed pane open.
Just about every program in the world has a Windows menu.
Forté is no exception, but unlike other programs, this menu only
shows you the windows that are already open, which is helpful only
in bringing a window to the top if it is buried under other windows. The
menu you probably want is View, from which you can open most
windows. Unlike other programs, this menu doesn't have checkmarks to tell
you which windows are open; but choosing an already open window from the
View menu does not close that window, so it doesn't hurt to try.
There is no installed server. The execution/debugging is not allowedThis sometimes happens when the HTML window is foremost. Bring another
window (such as your source code) to the front, and try running again.
From Ming-Yi Shiau: If you close your Form editor in the GUI Editing
mode, the next time you switch back to GUI Editing mode, the Form editor
won't show up as usual, and you cannot find it in the View menu
either. The solution is simple. Choose View -> Component Inspector,
and within the Component Inspector window, right-click the topmost
icon in the upper pane of the window, then choose Design This Container.
I think this is a memory problem. At least once when this happened,
other windows gradually became frozen as well. Restarting Forté solves
the problem; running with fewer other applications open at the same time
seems to prevent the problem from occurring.
You probably double-clicked on it by accident. Right-click on it and select
Design Whole Form.
Java causes invalid page fault in module Kernel32.DLL - Windows 98Whenever I accessed the Swing library, Windows 98 returned an "invalid page fault". Programs that do not use Swing worked fine. I found the following support document on Sun's support site and resolved the issue by disabling Microsoft Office Quick Start.
Solution Summary
|
You are using (or possibly Forté is using) some Java call that your
browser doesn't understand. You should use AWT for applets; Swing is less
likely to be understood by browsers. If you are not using Swing, the problem
is probably in code that you added. Open the Java Console window so that
you can view the error messages, and look for a NoSuchMethodError.
To open a Java Console window, do this:
Netscape 4: Choose Communicator -> Tools -> Java Console.
Internet Explorer 5: Every minor version of Internet Explorer does
this in a different, hard-to-find place; try Tools -> Internet
Options -> Advanced -> Java console enabled (requires restart).
Then restart Windows (restarting IE is not enough). Reopen IE and choose
View -> Java Console.
After jarring and unjarring my files, my program no longer works in Forté.
Forté creates and uses a file named .nbattrs.
Under UNIX (or when you telnet to UNIX), this file is invisible, and neither
* nor *.* will capture it. You can either add it to
the jar explicitly (by including it on the jar command line),
or you can move up to the enclosing directory, and jar the entire program
directory.
Sessions tabbed panel. Right click on the session (it's probably
the only thing in the left pane, and should be marked (Running)),
and choose Finish session.
If you are only running (not debugging) the program, go to the Execution
window (if it's not open, open it from the View menu).
Right click on the process (it's probably the only thing in the window)
and choose Terminate process.
Reformat Code command doesn't work.This command only works when entire lines are selected, not partial
lines. The easiest way to select entire lines is to click and drag in the
gutter (where the line numbers are).
From Tsung-Fang Tu: You can change the fonts, styles, and colors for the editor as follows.
Tools -> Options... from the main menu. Editor Settings (click on the "key"
next to it) in the Options window. Java Editor. Font Size
value in the right pane. Fonts & Colors, then click
on the ellipsis (...) that appears next to it. Block Comment, which is a light
gray italic), and change the font, size, and/or color. If you change the
color, note that you get a tabbed window (with tabs along the top)
that gives you many different ways to choose the color.Most changes happen immediately. You can't scroll the Source Editor
window while you are changing options, so it is helpful if you first make
sure the text you want to change is visible before you open the Options
window.
Project -> Settings.Documentation
on the left.Javadoc Executor Type to Internal
Javadoc.Ask for Destination Directory to true,
so that you can specify where to put the Javadoc each time it's generated.Javadoc Executors on the left to show its
subnodes.Internal Javadoc, and change Members
on the right to private.Doclets to get the
ellipsis (...) button. Click on it.Author from false to true.
Do the same for Version. Click OK.To generate Javadoc for all the classes in a directory, right-click that
directory in the Explorer window to bring out a menu and elect
Tools -> Generate Javadoc. Right-clicking on a single class in the
Explorer window will generate Javadoc for that class only.
Note: Forté uses the external javadoc executor by default.
Although we can change the Members options for the External
Javadoc Executor to private, it will not work unless
we change the Javadoc Executor Type to Internal Javadoc
Executor first and then change it back to External Javadoc
Executor.
Note #2: The internal Javadoc executor is not recommended for large
amounts of code (such as the entire JDK) unless you have at least 256MB
of RAM. This should not be a problem for our programs, though, and I have
had better luck with the internal executor.
Code Generation tab at the bottom of the window.Custom Creation Code button.new java.awt.TextArea("text", 10, 40, java.awt.TextArea.SCROLLBARS_VERTICAL_ONLY);
(don't forget the semicolon).
main method?main method. From the main menu
choose Build--->Set Arguments and then type in the arguments
as you would type them on the command line. If an argument includes a space,
enclose it in quotation marks. Then click OK.
General information
Yes. Use Forté's File -> Mount Filesystem...
command to select the folder containing all your BlueJ files. Forté
will not know about your GUI, so you won't be able to make any changes to
it in Forté; despite that, everything will work.
Yes. Use BlueJ's File -> Open Non BlueJ...
command to choose the folder containing all your Forté files.
In BlueJ's main window, it marks applets with an <applet>
tag. If your applet isn't so marked, you can't run it as an applet.
The solution is simply to recompile it.
If you get a message (from either system) saying that the class has the
wrong name--myProject instead of myProject/myClass--the
easiest solution I have found is to remove all the package
directives, save the file, then throw away the backup file (the one ending
with a ~). If you don't throw away the backup file, the
package directive seems to keep coming back.
Yes, but it's not a good idea.
In BlueJ (or any other editor) you will see //GEN-BEGIN and
//GEN-END comments; these mark regions that you should not edit.
These are the regions that show up as light blue areas in Forté.
Any changes or additions you make in this block of code will disappear permanently
the next time you use the file in Forté. There are also //GEN-FIRST
and //GEN-LAST comments; you should not edit the
lines on which these occur.
You can add and change code outside these regions. If you add any code
that Forté normally generates, such as GUI code, Forté will
not recognize it and "adopt" it (for example, if you create a
new Button, Forté's Form window won't display it), but the code will
still be there and will still function normally.
Yes and no. That is, you can get to it from within Forté, but Forté opens a browser to show you the files.
To set this up, you should have the Java API documentation downloaded
to your computer (this is a good idea in any case). Use the Javadoc tabbed
pane in the Explorer window. Right-click on Javadoc in this window, and
choose Add Directory... (if you have unzipped the API file
you downloaded), or choose Add JAR... (if the API file is still
a jar or a zip file). Find the file or directory,
select it and mount it.
The advantage of keeping the file zipped is that it uses much less disk
space. The disadvantage is that opening a zipped file directly from Internet
Explorer is slow and painful (but seems to work fine from within Forté.)
import statements?Forté uses fully-qualified names instead of import
statements. For example, where you might import java.awt.* and
later say Button myButton;, Forté will say java.awt.Button myButton;.
You can add import statements if you like; it doesn't hurt
to mix fully-qualified names and import statements in the same
class. Remember that import statements must be the very first
things in the file, after the package statement (if there is
one).
This is actually a fairly common style, and is perfectly legal in Java,
but it's a style I don't particularly like. You can either (1) put your
variables down there also, in order to maintain a consistent style, or (2)
put your variables at the top, because those are the ones that you, rather
than Forté, are responsible for (so they probably should be
in different places). At the moment I have a mild preference for the latter,
but it's up to you to decide what style you prefer.
From Kit Marlow: You can look at your project's files side-by-side, rather
than switching between overlapped files, by "cloning" one of them. You can
do this by right clicking on the desired file's tab at the bottom of the
Source Editor window, and selecting Clone view. A copy
of the file will appear, and you can size it or situate it however you like.
From Kit Marlow: A good way to see the errors in the output window and
in your code at the same time is the NextError function (press
F12). This function allows you to jump from error to error
in both windows simultaneously, with the offending lines highlighted in
both. Hitting the shift key plus F12 (PreviousError)
does the same thing, except in the reverse direction. I find this easier
than going between the output window and the source editor window for each
error.