Ich bekomme die Java Communications Api nicht installiert

xVentura

Aktives Mitglied
Hallo leute,

ich versuche schon seit Stunden die Java Communications Api Serial Programming/Serial Java - Wikibooks, open books for an open world zu installieren aber wenn ich dann im Java-Editor "
Code:
import javax.comm.*; import java.util.*;
" eintippe sagt der compiler mir sofort das [c]import javax.comm.*;[/code] nicht exzistiert.

Habe die Java Communications Api unter dieser Anweisung installiert:
Software Download and Install

und dann unter

To receive location beacons (via a receiver on a serial port), you need to install Java Serial Communication package.
To download

JavaComm 2.0 for Windows, click "here" <----

Kurz zu meinem System habe Win7 32bit.


Nun habe ich dies gemacht:

Unzip the file javacomm20-win32.zip. This will produce a hierarchy with a top level directory commapi.

The examples in this document assume that you have unzipped the javacomm20-win32.zip file in your C: partition and your JDK installation is in C:\jdk1.1.6. If you have installed JDK in an other location or unzipped javacomm20-win32.zip in an other location modify the example commands appropriately.

If you are installing the Java communications API into a JRE (Java runtime environment) follow the same instructions as for the JDK except where noted. See the additional instructions for running using the JRE.

Copy win32com.dll to your <JDK>\bin directory.

C:\>copy c:\commapi\win32com.dll to c:\jdk1.1.6\bin

Copy comm.jar to your <JDK>\lib directory.

C:\>copy c:\commapi\comm.jar c:\jdk1.1.6\lib

Copy javax.comm.properties to your <JDK>\lib directory.

C:\>copy c:\commapi\javax.comm.properties c:\jdk1.1.6\lib

The javax.comm.properties file must be installed. If it is not, no ports will be found by the system.

Add comm.jar to your classpath (do not do this step for a JRE installation).

If you don't have a classpath defined:

C:\>set CLASSPATH=c:\jdk1.1.6\lib\comm.jar

If you already have a classpath defined:

C:\>set CLASSPATH=c:\jdk1.1.6\lib\comm.jar;%classpath%


Several serial port sample applications are provided with this release. One of them is BlackBox. To run BlackBox, first add BlackBox.jar to your classpath:

C:\>set CLASSPATH=c:\commapi\samples\Blackbox\BlackBox.jar;%CLASSPATH%

Now you can run BlackBox:

C:\>java BlackBox

One sample driver, NullDriver, is included in the samples\NullDriver directory. This is useful for folks attempting to write a new driver for their own hardware.

---------------------------------------------------------------

Die erste Frage was ist der Unterschied zwischen JRE und JDK?
Ich habe ein Ordner Java indem ist ein Ordner Jre7 und jdk1.7.0_02. Indem Ordner jdk1.7.0_02 ist aber nochmal ein Jre Ordner. Nun habe ich jeweils 3x bin und lib Ordner. Ich habe die dateien kopiert und in jedem lib und bin es rein getan. Classpath konnte ich nicht setzen da ich schon ein Classpath hatte mit dem Wert ".;E:\Program Files\Java\jre7\lib\ext\QTJava.zip".

Kann mir jemand weiter helfen?


Kurz zu was ich Java Communications Api brauche:
Ich muss auf die Serielle Schnittstelle Rs 232 zugreifen um mit einem Mikrocontroller zu kommunizieren.

MfG Ventura
hoffe auf Hilfe
 
Zuletzt bearbeitet:
Das Verändern des Classpaths ist das a und O der Sache, ohne gehts nicht. Allerdings ist mir diese, ich nenns mal "harte", Installation etwas suspekt. Auch wenn in der Beschreibung drinsteht, das man's in die Java Installation reinkopieren soll, ist das nicht zwingend notwendig. Ich persöhnlich hab alle libs in einem Ordner in Documents liegenund füge diese dann nur in den Projekten wo ichs brauch über Eclipse zum Classpath hinzu, aber das ist Geschmackssache.
Also Classpath setzen: Entweder in der Console so wie es im Tutorial steht oder per Hand die neuen Einträge vor (oder nach) die alten reinkopieren, die einzelnen per ; trennen.
 
Erstmal danke.

Habe meine Umgebungsvariable nun geändert.

Systemvariable: Classpath
Wert: ".;E:\Program Files\Java\jre7\lib\ext\QTJava.zip;E:\Program Files\JavaEditor\JavaLibs\BlackBox\Blackbox.jar"

Geht immer noch nicht 🙁
 
Könntest du mir vielleicht helfen es in Eclipse zu implementieren?

ich versuche es gerade im JavaEditor da ich erst seit kurzem zu Eclipse gewechselt habe und Eclipse noch nicht ganz verstehe.

MfG
 
Verwendet dein Eclipse überhaupt das JDK in welches du die Lib kopiert hast?

Du kannst die Lib auch z.B. in ein Projekt oder an einen anderen Ort kopieren und im Eclipse über <dein Projekt> -> Properties -> Java Build Path -> Libraries -> Add Jar (falls die Jar in deinem Projekt liegt) bzw Add External Jar hinzufügen..dann sollt's klappen.
Liegt die dll aber nicht am korrekten Platz wird es zur Laufzeit krachen...dann musst du die Anwendung starten mit dem Parameter -Djava.library.path=<Pfad zum Ordner in dem die DLL liegt>

Gruß

Edith:
Prüf mal das JDK in Eclipse:
Window -> Preferences -> Java-> Installed JREs

Falls "deine" JDK nicht da drin ist für sie mittels "Add" hinzu, setze den Haken um sie als Default zu markieren und entferne "die alte Zeile"
 
danke sebastian!

mein code:
Java:
import java.io.*;
import java.util.*;
import javax.comm.*;

public class MeinePorts {

  public static void main(String[] args) {
    Enumeration MeinePorts = CommPortIdentifier.getPortIdentifiers(); //liefert Enumeration

    while (MeinePorts.hasMoreElements()) {  // tu es solange bis MeinePorts keine elemente mehr hat
      CommPortIdentifier portId = (CommPortIdentifier) MeinePorts.nextElement();
      System.out.println( portId.getName() ); //liefert Name der Ports wie COM1
      System.out.println(portId.getPortType() ); //liefert PORT_SERIAL oder PORT_PARALLEL
    }
  } // end of main

} // end of class MeinePorts

Console:
Fehler: Hauptklasse gnu.io.Configure konnte nicht gefunden oder geladen werden

Wieso nun gnu.io.configure??? ich glaube ich habe mal versucht die RxTx variante zu installieren mit JControl :/ wie bekomme ich diese nun weg?

MfG und danke schon mal
 
stell mal deine RunConfigurations auf das korrekte Projekt:

Run -> RunConfiguration -> und als MainClasse halt dein MeinePorts wählen
 
Ok nun Funktioniert es in Eclipse 🙂 Danke!

Konsole: "COM1
LPT1
LPT2"

Aber ich habe eigentlich vor es in JavaEditor zu programmieren und da läuft es immer noch nicht. 🙁
 

Zurück
Oben