This discussion is archived
12 Replies Latest reply: Mar 1, 2007 5:33 AM by 807596 RSS

win32com.dll

807596 Newbie
Currently Being Moderated
is anybody know where to find win32com.dll files

its used with comm.jar

TQ
  • 1. Re: win32com.dll
    807596 Newbie
    Currently Being Moderated
    You can find it in the following package

    http://www.cs.uml.edu/~fredm/courses/91.305/software/JDK118-javaxcomm.zip

    and if you succeed in detecting the serial port with javax.comm just tell me about your advancement

    more information there
    http://java.sun.com/developer/JDCTechTips/2002/tt0122.html
    http://www.cs.uml.edu/~fredm/courses/91.305-fall04/javasetup.shtml

    all the best
  • 2. Re: win32com.dll
    807596 Newbie
    Currently Being Moderated
    I would like to know whether you got the solution for detecting serial port with javax.comm API. If so, will you please help me in that?
  • 3. Re: win32com.dll
    807596 Newbie
    Currently Being Moderated
    I got it to work =). Thank god.

    I had to put the .dll in the system32 directory. I put the properties file in the jre/lib (I also put the dll here, but it did not work on its own). I added the .jar file as an additional archived source (I'm using eclipse). And then was able to run a GPS connectionTest without fail.

    Here is that source code which you may want to use as reference in terms of detecting the serial port.
    http://gpslib4j.sourceforge.net/
  • 4. Re: win32com.dll
    807596 Newbie
    Currently Being Moderated
    Thanks alot for that link, i have been searching like crazy befor looking in forum, :)
  • 5. Re: win32com.dll
    807596 Newbie
    Currently Being Moderated
    I too was searching for hours, thank you so much for the link. It worked for me, what a relief!
  • 6. Re: win32com.dll
    807596 Newbie
    Currently Being Moderated
    hey guys.....plzzz help me out....

    1st of all i don't hv the properties file.....

    secondly....i need to know how can i get modem inputs in my PC....



    I m doin a project on takin alphanumeric input from modem which will b typed by the phone user and performing a search in my database and on that searched tuple i need to take that and convert to speech which again i need to read back to the phone via modem.

    its a bit type of IVR project....

    PLzzzzz help me out guys....
  • 7. Re: win32com.dll
    807596 Newbie
    Currently Being Moderated
    guys i got the properties file...me too a nut....but can u plzz help me out on my project details wch i hv listed in my previous post...
  • 8. Re: win32com.dll
    807596 Newbie
    Currently Being Moderated
    The above link did not work for me, so after some searching, I found win32comm.dll in this zip file ->

    ftp://www6.software.ibm.com/software/developer/library/i-barcode.zip
  • 9. Re: win32com.dll
    807596 Newbie
    Currently Being Moderated
    have you been succeded? ..me too need some advices - i just follow to simple example (from tutorial) and nothing happened - can not find any ports..
  • 10. Re: win32com.dll
    807596 Newbie
    Currently Being Moderated
    Some things I've found out about using javax.comm (using JDK118-javaxcomm.zip; link in posting 2 by Yanos):
    - comm.jar has to be on the classpath (for sure ;-))
    - win32com.dll is allowed to be in any dir but you have to point to that dir using the system property java.library.path: e.g.
    java -Djava.library.path=<the dir that contains win32com.dll> -classpath ...

    The search strategy used to find javax.comm.properties:
    - first: searching for: System.getProperty("java.home") + File.separator + "lib" + File.separator + "javax.comm.properties"
    - if not found: javax.comm.properties is searched in the same dir comm.jar is stored; that's done by tokenizing System.getProperty("java.class.path") using a StreamTokenizer using File.pathSeparatorChar (";" on Win32) as token delimiter;

    Because "_" and ":" are not defined for that StreamTokenizer as "normal" characters that are allowed inside a filename it won't work if you have a "_" inside the path to your comm.jar and it won't work if comm.jar is located on another drive than the current!!!!! ;-(((

    Remember that for parsing / tokenizing any path always the system dependend File.pathSeparatorChar / File.separatorChar is used
  • 11. Re: win32com.dll
    807596 Newbie
    Currently Being Moderated
    Initialization of CommPortIdentifier is really bad. The attached class does (for me) a better job. It removes the restrictions (no "_", ":" in classpath) as described in my previous posting. See JavaDoc on how to use. Please reply if it works for you too.
    import java.io.File;
    import java.io.IOException;
    import java.io.StreamTokenizer;
    import java.io.StringReader;
    import java.lang.reflect.Field;
    import java.lang.reflect.Method;
    
    import javax.comm.CommPortIdentifier;
    
    /**
     * This class tries to do a better initialization of javax.comm than 
     * javax.comm.CommPortIdentifier (date: 15th Nov 1998) does because
     * the original implementation does not tokenize the classpath on Win32 systems
     * in a correct way. 
     * <P/>
     * Just force the loading of that class does the job:
     * <pre>
     * Class.forName( "JavaXCommInitializer" );
     * </pre>
     * or
     * <pre>
     * Class c = JavaXCommInitializer.class;
     * </pre>
     * If not already done this class first forces the initialization of the original
     * javax.comm.CommPortIdentifier (by calling getPortIdentifiers()) and runs the own initialization
     * only if no ports were returned.
     * <P/>
     * Therefore access to private methods of javax.comm.CommPortIdentifier using the reflection
     * API is necessary ;-). This will not be possible if you have a SecurityManager installed and not granted
     * the necessary permissions.
     * <P/>
     * Most of the code is based on a decompiled version of javax.comm.CommPortIdentifier downloaded from 
     * http://www.cs.uml.edu/~fredm/courses/91.305/software/JDK118-javaxcomm.zip
     */
    public class JavaXCommInitializer {
        private JavaXCommInitializer() {}
    
        private static String findPropFile() {
            String s = System.getProperty("java.class.path");
            StreamTokenizer streamtokenizer = new StreamTokenizer(((java.io.Reader) (new StringReader(s))));
            streamtokenizer.whitespaceChars(((int) (File.pathSeparatorChar)), ((int) (File.pathSeparatorChar)));
            streamtokenizer.wordChars(((int) (File.separatorChar)), ((int) (File.separatorChar)));
            // characters allowed in a path (as long as they're not conflicting with File.pathSeparatorChar
            char[] normalChars = { '.', ':', '_' }; 
            for( int i = 0; i < normalChars.length; i++ ) {
                char c = normalChars;
    if( c != File.pathSeparatorChar ) {
    streamtokenizer.ordinaryChar(c);
    streamtokenizer.wordChars(c, c);
    }
    }

    try {
    while(streamtokenizer.nextToken() != -1) {
    int i = -1;
    if(streamtokenizer.ttype == -3 && (i = streamtokenizer.sval.indexOf("comm.jar")) != -1) {
    String s1 = streamtokenizer.sval;
    File file = new File(s1);
    if(file.exists()) {
    String s2 = s1.substring(0, i);
    if(s2 != null)
    s2 = s2 + "." + File.separator + "javax.comm.properties";
    else
    s2 = "." + File.separator + "javax.comm.properties";
    File file1 = new File(s2);
    if(file1.exists())
    return file1.getCanonicalPath();
    else
    return null;
    }
    }
    }
    }
    catch(IOException _ex) { }
    return null;
    }

    private static void callPrivateMethod( Class clazz, String methodName, Class[] argTypes, Object[] args )
    throws
    Exception {
    Method m = clazz.getDeclaredMethod( methodName, argTypes );
    m.setAccessible( true );
    m.invoke( null, args );
    }

    private static void setPrivateAttribute( Class clazz, String attrName, Object value )
    throws
    Exception {
    Field f = clazz.getDeclaredField( attrName );
    f.setAccessible( true );
    f.set( null, value );
    }

    static {
    // call the default initialization of javax.comm ...
    if( !CommPortIdentifier.getPortIdentifiers().hasMoreElements() ) {
    // ... if no ports found try to do it better ;-)

    // no need for loading javax.comm.properties from <JAVA_HOME>/lib/javax.comm.properties
    // as this is done very well by default init in CommPortIdentifier

    // search propFile
    String myPropfilename = findPropFile();
    try {
    if( myPropfilename != null ) {
    // loadDriver(propfilename);
    callPrivateMethod( CommPortIdentifier.class, "loadDriver", new Class[]{ String.class }, new Object[]{ myPropfilename } );
    // propfilename = myPropfilename;
    setPrivateAttribute( CommPortIdentifier.class, "propfilename", myPropfilename );
    }
    }
    catch(Exception e) {
    System.err.println(((Object) e));
    }
    }
    }
    }
  • 12. Re: win32com.dll
    807596 Newbie
    Currently Being Moderated
    Hi people , grretings for all .
    I just want to know if the win32com.dll file is actually being supported by Sun .
    I think that it has been replaced by rxtx project .

    I don't know actually .

    Thanks .