Hallo! Ich habe mir die Java-Library CHARVA von http://www.pitman.co.za/projects/charva/index.html heruntergeldan und auch entpackt. Doch was soll ich nun machen? Ein Blick in die README sagt mir nicht wirklich viel, bzw. funktionieren die Anweisungen nicht... Habe Java 1.6
Java-Library CHARVA einbinden
Anmeldungsdatum: Beiträge: 39 |
|
![]() Anmeldungsdatum: Beiträge: 17604 Wohnort: Berlin |
Welche Anweisungen funktionieren nicht? Wie äußert sich dieses nicht-funktionieren? Kompilefehler, Laufzeitfehler, semantische Fehler, Was willst Du denn überhaupt damit machen? |
Anmeldungsdatum: Beiträge: 352 |
Slackubuntu schrieb:
In dem Archiv gibt es zwei Dateien: chavra/java/dist/lib/charva.jar und chavra/c/lib/libTerminal.so. Das eine ist der Java-Teil der Library, das andere der Native-Teil der Library (die Library verwendet JNI). Die .jar-Datei musst du in den Classpath mit aufnehmen, beispielsweise unter Eclipse: rechte Maustaste auf .jar → Build Path → Add to Build Path. Dann musst du noch den Native-Teil damit verbinden: rechte Maustaste auf .jar → Properties → Native Library → External Folder und das Verzeichnis wählen, in dem sich die .so-Datei befindet. |
(Themenstarter)
Anmeldungsdatum: Beiträge: 39 |
ähmmm... vielleicht dumme Frae... wie kann ich denn jetzt die Native Library "außerhalb" von eclipse benutzen? |
Anmeldungsdatum: Beiträge: 352 |
Slackubuntu schrieb:
Das jar bindest du ganz normal mit |
(Themenstarter)
Anmeldungsdatum: Beiträge: 39 |
OK, hab ich soweit hingekriegt, bekomme aber beim Ausführen eine Fehlermeldung: Exception in thread "main" java.lang.NoClassDefFoundError: //main Caused by: java.lang.ClassNotFoundException: ..main at java.net.URLClassLoader$1.run(URLClassLoader.java:217) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:205) at java.lang.ClassLoader.loadClass(ClassLoader.java:321) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294) at java.lang.ClassLoader.loadClass(ClassLoader.java:266) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:334) Could not find the main class: ./main. Program will exit. Gerade die letzte Zeile irretiert mich: meine Class hat eine main-methode (lasst euch nicht davon irritieren, dass meine Klasse auch main heist...) Hier ist mal mein Programm-Code: import charvax.swing.*; public class main extends JFrame{ public main(){ super(); JTextField JF = new JTextField(); add(JF); setVisible(true); } public static void main(String[] args) { main m = new main(); } } Weiß jemand, was die Fehlermeldung bedeutet? |
![]() Anmeldungsdatum: Beiträge: 17604 Wohnort: Berlin |
Slackubuntu schrieb:
Doch, gerade damit schießt Du Dir ja selbst ins Knie. Klassennamen sollen großgeschrieben werden, damit auch der Konstruktor. Wie rufst Du Dein Programm auf, wo ist die Klasse, die main enthält, von wo startest Du das Programm? |
Anmeldungsdatum: Beiträge: 352 |
Slackubuntu schrieb:
Du brauchst wohl auch noch die jars für's Logging (mit im Zip-Archiv drin) und musst auch noch das Arbeitsverzeichnis mit in den Classpath aufnehmen. Zur Demo mal alles zusammen in einem Verzeichnis: $ ls charva.jar commons-logging-api.jar commons-logging.jar libTerminal.so log4j-1.2.8.jar main.java $ javac -classpath charva.jar main.java $ java -classpath charva.jar:commons-logging.jar:log4j-1.2.8.jar:. -Djava.library.path=. main Übrigens ist es keine keine gute Idee Klassen wie Methoden zu benennen. Klassennamen sollten in Java immer mit Großbuchstaben beginnen. |
(Themenstarter)
Anmeldungsdatum: Beiträge: 39 |
Danke, es funktioniert!!! Habe vergesen die log4j-1.2.8.jar mit in den Classpath zu nehmen. Danke für die Hilfe von euch beiden. Achja, um noch mal die Fragen von user unknown vom Anfang zu beantworten (sofern sie sich nicht schon ergeben haben 😉 ):
Naja, wenn du dir mal die README (bzw. halt /doc/Download.html) durchließt: 1. Download the latest zipfile from http://sourceforge.net/projects/charva. 2. Change to a suitable directory ($HOME/work, say) and extract the contents using the command: unzip charva-x.y.z.zip This will create a directory tree called "charva" in the current directory. Set the environment variable CHARVA_HOME to the full pathname of this new directory. 3. Set the environment variable JAVA_HOME to the name of your JDK installation directory, for example: export JAVA_HOME=/usr/local/jdk1.4.2 4. At this stage, if you have JDK1.3, JDK1.4 or JDK1.5 installed, you can run the test program as described in step 8 below (precompiled libraries for Linux, compiled with J2SDK1.4.2, are included in the download package, as $CHARVA_HOME/c/lib/libTerminal.so and $CHARVA_HOME/java/dist/lib/charva.jar). I have tested Charva with RedHat Linux 7, 8 and 9, Fedora 3 and 4, CentOS 4, Windows 98, Windows 2000, and Windows XP. Others have ported Charva to various other flavors of Unix. If you are running some other version of Unix or have a different version of the JDK, you will have to build the libraries and the test program as described in the following steps. Operating-system-specific Makefiles are provided in the $CHARVA_HOME/c/src directory. The required DLL for Windows is provided in the $CHARVA_HOME/c/lib directory. 5. Make sure you have Apache Ant installed. Instructions for setting up Ant are available on its website. 6. Compile the Java classes, generate the JNI header file, and compile the "tutorial" program with the following commands: cd $CHARVA_HOME ant compile ant javah ant compile-test 7. Build the JNI (Java Native Interface) library libTerminal.so by entering the following commands (you need to have the ncurses-devel RPM, i.e. the ncurses header files, installed for this step to work): ant makeDLL (This has been tested on Linux: if it doesn't work for you, you can generate the shared library "manually" with the following commands): cd $CHARVA_HOME/c/src make -f os-specific-makefile 8. Run the tutorial program by entering the following commands: cd $CHARVA_HOME sh test.sh (If you are running Windows, use wintest.bat instead). Two different versions (a Swing version and a CHARVA version) of the tutorial program are provided in the tarball. The source code of the two programs is almost identical; they differ in only a few lines. To run the Swing version instead of the Charva version, type "sh test.sh swing" instead. Note that this program uses the standard Java Swing GUI, and therefore your X display must be up and running for this program to work. Note that the input/output device of any Charva program can be: * a traditional serial terminal, such as a VT100 or VT220, logged directly into the computer's serial port * an "xterm" terminal emulator on an X-windows display (don't use the "gnome-terminal" application that comes with GNOME; it's buggy) * a remote terminal emulator (such as PuTTY; don't even try the Telnet program shipped with Windows, it's broken) logged into the host computer via a Telnet or SSH session. In any of these cases you have to ensure that the TERM environment variable is set correctly to match the terminal type. The tutorial program displays a frame with the usual menu-bar at the top. You can select a menu by pressing the LEFT or RIGHT cursor keys, then pressing ENTER on the selected menu. Each menu item pops up a dialog that demonstrates some feature(s) of CHARVA. Moving from one field to the next within a dialog-box is done by pressing the TAB key. You should also be able to move from each field to the previous field by pressing the BACK-TAB key; but the mapping of the BACK-TAB key is not standard on all terminals. Many terminals map BACK-TAB to SHIFT+TAB; if in doubt, refer to the FAQ page. You should be able to edit text input fields by using the BACKSPACE and DELETE keys, and navigate within textfields using the HOME, END, LEFT and RIGHT cursor keys. If your terminal-emulator reports mouse-events, you should be able to move the focus to any component in the topmost frame (or dialog-box) by clicking on the component. Clicking on a JButton, JComboBox or JMenuItem invokes it. Clicking an item inside a JList moves the current row to the item; double-clicking the item selects/deselects it. Clicking inside a JTextField or JTextArea moves the caret (the text insertion point) to where the mouse was clicked. If any of these keys or the mouse does not work, check whether the terminfo description of your terminal is correctly set up. Also see the FAQ page You can view the API documentation of the CHARVA library by pointing your Web browser at $CHARVA_HOME/docs/api/index.html (on your local machine). You can also browse the API documentation online. For permanent installation, you just need to ensure that the directory containing the libTerminal.so library file is included in your library search path, which is specified as follows: * On Linux and Solaris it is specified by the environment variable LD_LIBRARY_PATH * On AIX the environment variable is LIBPATH * On HP-UX the environment variable is SHLIB_PATH, and the filename must be libTerminal.sl * On Win32 the library file is Terminal.dll and you specify the search path with the command-line option -Djava.library.path=directory_containing_Terminal.dll You also need to put the JAR file (charva.jar) into your Java CLASSPATH. Look at the script $CHARVA_HOME/test.sh for an example of how to do this on Linux. If you want to build a Charva application as a native executable that you can deploy on a system that doesn't have a Java interpreter, have a look at the file "Makefile.gcj.txt" in the c/src directory of the Charva distribution. I would welcome your feedback about the usefulness and usability of the CHARVA package, and about errors or omissions in these web pages. Please send me your comments at rob@pitman.co.za Ab da, wo man irgenwas mit ant machen soll (was ist das eigentlich (ant)?) bekomme ich haufenweise Fehlermeldungen, ant ist aber installiert (alle Pakete in den Repostories)
ich wollte halt die Klassen der Libraray benutzen. Mit Charva kann man "GUI", mit awt oder swing erstellt im Terminal anzeigen. |