This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

1.3.2-1: problem running Expect from JNI.

I have modified Mumit Khan's simple JNI example from
to make a native Expect library call using JNI.
What I did was add a line to call the exp_popen() function from the Expect
library libexpect526.a. (installed with cygwin setup).
What is displayed on the console when running the java program is a java
usage message as if the command 'java' had been entered on the terminal. The
Expect library call exp_popen is a wrapper to Expect's spawn and I am asking
it to spawn an FTP session.

This is the output:

~/oware35/native/java-jni/c:java Main
Java JNI
HOME = /cygdrive/d/work
Usage: java [-options] class [args...]
           (to execute a class)
   or  java -jar [-options] jarfile [args...]
           (to execute a jar file)

where options include:
    -cp -classpath <directories and zip/jar files separated by ;>
                  set search path for application classes and resources
                  set a system property
                  enable verbose output
    -version      print product version and exit
    -showversion  print product version and continue
    -? -help      print this help message
    -X            print help on non-standard options
      0 [main] java 200 sync_with_child: child 97(0x364) died before
initialization with status code 0x1
    298 [main] java 200 sync_with_child: *** child state waiting for longjmp
After native call

This is the JNI source:

#include <stdio.h>
#include <stdlib.h>
#include <jni.h>
#include "HelloWorld.h"

#include "/usr/include/expect.h"

Java_HelloWorld_displayHelloWorld (JNIEnv *env, jobject obj)
  char *home;
  printf("Java JNI\n");
  home = getenv ("HOME");
  printf("HOME = %s\n", (home) ? home : "(NULL)");

//      exp_popen("ls");


Attached is the makefile.

Finding a reliable NT port of Expect that I can call from java has been
difficult. If anyone has done this before or knows someone who can help me I
would appreciate it.

Vaughn Balchunas
Sr. Software Engineer
Dorado Software

Unsubscribe info:
Bug reporting:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]