If trying to compile and run javax.comm programs, you may need to repeat the install for the SDK and for the Java runtime on windows.
eg.
For the sdk:
Copy files to directory: C:\j2sdk1.4.2_05\jre
For the runtime:
Copy files to: C:\Program Files\Java\j2re1.4.2_05
C:\test>type PortList.java
import javax.comm.*;
import java.util.*;
public class PortList
{
public static void main(String [] args)
{
Enumeration portList = CommPortIdentifier.getPortIdentifiers();
while(portList.hasMoreElements()) {
CommPortIdentifier portId = (CommPortIdentifier)portList.nextElement();
if( portId.getPortType() ==
CommPortIdentifier.PORT_SERIAL)
{
System.out.println("Serial port: " +
portId.getName());
} else if (portId.getPortType() ==
CommPortIdentifier.PORT_PARALLEL)
{
System.out.println("Parallel port: " +
portId.getName());
} else
System.out.println("Other port: " +
portId.getName());
}
}
}
Expected Output:
Serial port: COM1
Serial port: COM2
Parallel port: LPT1
Parallel port: LPT2
If you get java.lang.NoClassDefFoundError you don't have javax.comm installed properly.
C:\test>type showenv.java
import java.util.*;
public class showenv {
public showenv(){}
public static void main(String args[]) {
for (Enumeration e=System.getProperties().propertyNames();
e.hasMoreElements();) {
String key = (String)e.nextElement();
String value = System.getProperty(key);
System.out.println(key+" = "+value);
}
}
}
C:\test>java showenv
java.runtime.name = Java(TM) 2 Runtime Environment, Standard Edition
sun.boot.library.path = C:\Program Files\Java\j2re1.4.2_05\bin
java.vm.version = 1.4.2_05-b04
java.vm.vendor = Sun Microsystems Inc.
java.vendor.url = http://java.sun.com/
path.separator = ;
java.vm.name = Java HotSpot(TM) Client VM
file.encoding.pkg = sun.io
user.country = US
sun.os.patch.level = Service Pack 4
java.vm.specification.name = Java Virtual Machine Specification
user.dir = C:\test
java.runtime.version = 1.4.2_05-b04
java.awt.graphicsenv = sun.awt.Win32GraphicsEnvironment
java.endorsed.dirs = C:\Program Files\Java\j2re1.4.2_05\lib\endorsed
os.arch = x86
java.io.tmpdir = C:\DOCUME~1\me2000\LOCALS~1\Temp\
line.separator =
java.vm.specification.vendor = Sun Microsystems Inc.
user.variant =
os.name = Windows 2000
sun.java2d.fontpath =
java.library.path = C:\WINNT\system32;.;C:\WINNT\system32;C:\WINNT;D:\Perl\bin\;C:\Perl\bin\;C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;C:\vim\vim58\;C:\j2sdk1.4.2_05\bin;C:\ant\bin
java.specification.name = Java Platform API Specification
java.class.version = 48.0
java.util.prefs.PreferencesFactory = java.util.prefs.WindowsPreferencesFactory
os.version = 5.0
user.home = C:\Documents and Settings\me2000
user.timezone =
java.awt.printerjob = sun.awt.windows.WPrinterJob
file.encoding = Cp1252
java.specification.version = 1.4
user.name = me2000
java.class.path = .
java.vm.specification.version = 1.0
sun.arch.data.model = 32
java.home = C:\Program Files\Java\j2re1.4.2_05
java.specification.vendor = Sun Microsystems Inc.
user.language = en
awt.toolkit = sun.awt.windows.WToolkit
java.vm.info = mixed mode
java.version = 1.4.2_05
java.ext.dirs = C:\Program Files\Java\j2re1.4.2_05\lib\ext
sun.boot.class.path = C:\Program Files\Java\j2re1.4.2_05\lib\rt.jar;C:\Program Files\Java\j2re1.4.2_05\lib\i18n.jar;C:\Program Files
\Java\j2re1.4.2_05\lib\sunrsasign.jar;C:\Program Files\Java\j2re1.4.2_05\lib\jsse.jar;C:\Program Files\Java\j2re1.4.2_05\lib\jce.jar
;C:\Program Files\Java\j2re1.4.2_05\lib\charsets.jar;C:\Program Files\Java\j2re1.4.2_05\classes
java.vendor = Sun Microsystems Inc.
file.separator = \
java.vendor.url.bug = http://java.sun.com/cgi-bin/bugreport.cgi
sun.cpu.endian = little
sun.io.unicode.encoding = UnicodeLittle
sun.cpu.isalist = pentium i486 i386
|