aspose file tools*
The moose likes Beginning Java and the fly likes [SOLVED] NoClassDefFoundError: javax/comm/CommPortIdentifier Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "[SOLVED] NoClassDefFoundError: javax/comm/CommPortIdentifier " Watch "[SOLVED] NoClassDefFoundError: javax/comm/CommPortIdentifier " New topic
Author

[SOLVED] NoClassDefFoundError: javax/comm/CommPortIdentifier

Torstein Mauseth
Greenhorn

Joined: Feb 01, 2012
Posts: 5
Hello,

I'm trying to import javax.comm.CommPortIdentifier;
Compiling it works just fine, but getting a nasty error when trying to run my ComPort.class file





classpath is: set CLASSPATH=.
%JAVA_HOME% is set to C:\Program Files\Java\jdk1.7.0_02
path in Environment Variables is set to: C:\Program Files\Java\jdk1.7.0_02\bin;C:\Program Files\Java\jdk1.7.0_02

File location:
comm.jar
%JAVA_HOME%/lib
%JAVA_HOME%/jre/lib/ext

win32com.dll
%JAVA_HOME%/bin
%JAVA_HOME%/jre/bin
%windir%System32

javax.comm.properties
%JAVA_HOME%/lib
%JAVA_HOME%/jre/lib


also added this to java.policy file
permission java.io.FilePermission "javax.comm.properties", "read";


Anyone got a clue how to solve this?
Googled for hours and no luck so far.
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
Where is the javax.comm library? It's not part of JSE, so you need to add the jar file especially.

I generallay advise not to use the CLASSPATH variable; I generally find it's causing more problems than it solves. Instead, specify all libraries using the "-cp" option.
Torstein Mauseth
Greenhorn

Joined: Feb 01, 2012
Posts: 5
downloaded it from http://llk.media.mit.edu/projects/picdev/software/javaxcomm.zip

edit: as far as I know, "set classpath=." is the default address

also, when typing: java -cp %JAVA_HOME%\lib\comm.jar
i got this, Error: Could not find or load main class "Files\Java\jdk1.7.0_02\lib\comm.jar"

I modified JAVA_HOME to c:\progra~1\jdk1.7.0_02\lib
and tested: java -cp -jar %JAVA_HOME%\lib\comm.jar
still same result: Error: Could not find or load main class C:\progra~1\jdk1.7.0_02\lib\lib\comm.jar
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
Paths that have spaces in them are problematic; you may have to use double quotes around those like

-cp "%JAVA_HOME%\lib\comm.jar"
Torstein Mauseth
Greenhorn

Joined: Feb 01, 2012
Posts: 5
Tim Moores wrote:Paths that have spaces in them are problematic; you may have to use double quotes around those like

-cp "%JAVA_HOME%\lib\comm.jar"


This does not work either.

Seems like I need to add -jar, but same problem here.
-cp -jar "%JAVA_HOME%\lib\comm.jar"


tested this as well, no luck
java ComPort -cp "%JAVA_HOME%/lib/comm.jar"
I must be doing something terribly wrong :/
Torstein Mauseth
Greenhorn

Joined: Feb 01, 2012
Posts: 5
Yay, fixed it!

added/edited this to Environment Variables
JAVA_HOME C:\Progra~1\Java\jdk1.7.0_02
CLASSPATH .;%JAVA_HOME%\lib\comm.jar



Is there another way to add class paths for jar files?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39409
    
  28
And welcome to the Ranch
Torstein Mauseth
Greenhorn

Joined: Feb 01, 2012
Posts: 5
Thank you so much.

Oh for others that may read this.
Seems like the java files I linked to is outdated.

rtxtcomm worked better

http://www.jcontrol.org/download/rxtx_en.html

import gnu.io.CommPortIdentifier;
import gnu.io.PortInUseException;
import gnu.io.SerialPort;

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: [SOLVED] NoClassDefFoundError: javax/comm/CommPortIdentifier