Ich hab ein proplem beim compilen von java code.
Jedeamanl bekomme ich folgende error message.
C:\j2sdk1.4.1_07\javaap>javac triangle.java
triangle.java:12: '}' expected
}
^
triangle.java:3: class Triangle is public, should be declared in a file named Tr
public class Triangle extends Applet {
^
2 errors
C:\j2sdk1.4.1_07\javaap>
Ich verwende neuste version JCreator LE und java development kit j2sdk1.4.1_07.
Code sieht so aus:
[
Code:
import java.awt.*;
import java.applet.Applet;
public class Triangle extends Applet {
public void paint (Graphics g){
int bottomX=80;
int bottomY=200;
int base=100;
int height=100;
g.drawLine(bottomX,bottomY,bottomX+base,bottomY);
g.drawLine(bottomX+base,bottomY,bottomX+base/2,bottomY-height);
g.drawLine(bottomX+base/2,bottomY-height, bottomX,bottomY);
}
}
where <options> include:
-debug Start the applet viewer in the Java debugger
-encoding <encoding> Specify character encoding used by HTML files
-J<runtime flag> Pass argument to the java interpreter
The -J option is non-standard and subject to change without notice.
C:\j2sdk1.4.1_07\javaap>appletviewer Triangle.java -debug
Initializing jdb ...
>
>
> c:
Command 'c:' is not valid until the VM is started with the 'run' command
> run
run sun.applet.Main Triangle.java
Set uncaught java.lang.Throwable
Set deferred uncaught java.lang.Throwable
>
VM Started:
The application exited
Code:
import java.awt.*;
import java.applet.Applet;
public class Triangle extends Applet {
public void paint (Graphics g){
int bottomX=80;
int bottomY=200;
int base=100;
int height=100;
g.drawLine(bottomX,bottomY,bottomX+base,bottomY);
g.drawLine(bottomX+base,bottomY,bottomX+base/2,bottomY-height);
g.drawLine(bottomX+base/2,bottomY-height, bottomX,bottomY);
}
}
1)
Der Befehl zum starten lautet
java Triangle
das .java (eigentlich willst du eh die .class ausführen) darfst du nicht dazu scheiben.
2)
Du hast ein Applet, mit der java.exe lassen sich aber nur Javaprogramme (also Klassen mit einer main Methode) starten.
3)
Der appletviewe erwartet eine html Datei. Mit einer class Datei alleine kann er nichts anfangen.
Entweder du schreibst eine passende html Datei, oder du lässt dir das Applet in einer IDE anzeigen.
Danke nochmal ich werds versuchen.
also der appletviewer kann nur html dateien lesen, das bedeuted ich werde den applet in meine html embeden und dann laeufts..
ok
Tausen dank nochmal