Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 853513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T07:46:16+00:00 2026-05-15T07:46:16+00:00

I would like to be able to operate a scanner from my AIR application.

  • 0

I would like to be able to operate a scanner from my AIR application. Since there’s no support for this natively, I’m trying to use the NativeProcess class to start a jar file that can run the scanner. The Java code is using the JTwain library to operate the scanner. The Java application runs fine by itself, and the AIR application can start and communicate with the Java application. The problem seems to be that any time I attempt to use a function from JTwain (which relies on the JTwain.dll), the application dies IF AIR STARTED IT.

I’m not sure if there’s some limit about referencing dll files from the native process or what. I’ve included my code below

Java code-

    while(true)
    {
        try {
            System.out.println("Start");
            text = in.readLine();
            Source source = SourceManager.instance().getCurrentSource();
            System.out.println("Java says: "+ text);
        }
        catch (IOException e)
        {
            System.err.println("Exception while reading the input. " + e);
        }
        catch (Exception e) {
            System.out.println("Other exception occured: " + e.toString());
        }
        finally {
        }
    }   
}

Air application-

        import mx.events.FlexEvent;

        private var nativeProcess:NativeProcess;
        private var npInfo:NativeProcessStartupInfo;
        private var processBuffer:ByteArray;
        private var bLength:int = 0;

        protected function windowedapplication1_applicationCompleteHandler(event:FlexEvent):void
        {
            var arg:Vector.<String> = new Vector.<String>;
            arg.push("-jar");
            arg.push(File.applicationDirectory.resolvePath("Hello2.jar").nativePath);

            processBuffer = new ByteArray;

            npInfo = new NativeProcessStartupInfo;
            npInfo.executable = new File("C:/Program Files/Java/jre6/bin/javaw.exe");
            npInfo.arguments = arg;

            nativeProcess = new NativeProcess;
            nativeProcess.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, onStandardOutputData);
            nativeProcess.start(npInfo);
        }

        private function onStandardOutputData(e:ProgressEvent):void
        {
            tArea.text += nativeProcess.standardOutput.readUTFBytes(nativeProcess.standardOutput.bytesAvailable);
        }


        protected function button1_clickHandler(event:MouseEvent):void
        {
            tArea.text += 'AIR app: '+tInput.text + '\n';
            nativeProcess.standardInput.writeMultiByte(tInput.text + "\n", 'utf-8');
            tInput.text = '';
        }


        protected function windowedapplication1_closeHandler(event:Event):void
        {
            nativeProcess.closeInput();
        }

    ]]>
</fx:Script>
<s:Button label="Send" x="221" y="11" click="button1_clickHandler(event)"/>
<s:TextInput id="tInput" x="10" y="10" width="203"/>
<s:TextArea id="tArea" x="10" width="282" height="88" top="40"/>

I would love some explanation about why this is dying. I’ve done enough testing that I know absolutely that the line that kills it is the SourceManager.instance().getCurrentSource(). I would love any suggestions. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T07:46:17+00:00Added an answer on May 15, 2026 at 7:46 am

    When calling Java add this -Djava.library.path=location_of_dll to the command line

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to be able to use the Tab key within a text
I would like to be able to obtain all the parameter values from the
I would like to be able to define and use a custom type in
I have an application A that I would like to be able to invoke
I would like to be able to run ruby and perl scripts from build.xml
I would like to be able to control a USB device from a web
I would like to be able to loop through all of the defined parameters
We would like to be able to nightly make a copy/backup/snapshot of a production
I would like to be able to display some dynamic text at the mouse
I would like to be able to predict what will be in the resulting

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.