The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum
 Origin Forum
 Calling Origin from command line and Java run time
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

newuser_ca

70 Posts

Posted - 06/06/2012 :  2:58:41 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
OriginPro 8.6 in Win7

I have a user interface written in Java. There is a button to call Origin. The button can open Origin window and load project but it didn't run the script after "-r".

However, I have no problem running this in Command Prompt.

Here is the function call:
c:\Program Files\OriginLab\Origin\origin86_64.exe" -r (import(CSVFILE);) c:\TDV\import.opj

where import.opj is Origin project and "import" is the function in the project.

Java runtime didn't run the script "import(CSVFILE);". It worked well in the Command Prompt.

Can anybody tell me what is wrong?

Thanks.

Sophy

China
Posts

Posted - 06/06/2012 :  10:25:26 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi, We check the code and it works fine with Java, and I'd like to share the code that works(Tested in NetBeans IDE 7.0).


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package launcho;
/**
 *
 * @author OriginLab
 */
public class LaunchO {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        System.out.println("---This is demo project from OriginLab---");
        
        String strCmd = "K:\\OriginPro86\\Origin86_64.exe -r (import(K:\\data.csv);) K:\\importCSS.opj";
        try
        {
            String strRet = exec(strCmd);
        }
        catch(Exception e)
        {
            System.out.println("Exception while execute DOS command");
        }
    }
    public static String exec(String strCmd) throws Exception
    {
        Runtime rt = Runtime.getRuntime();
        Process proc = rt.exec(strCmd);
        int nRet = proc.waitFor();
        if ( nRet != 0 )
        {
            return "Exit code not right";
        }
        return "Successfully executed";
    }
}

and the Origin C code which is attached to the project is like the following:

#include <Origin.h>
////////////////////////////////////////////////////////////////////////////////////

//#pragma labtalk(0) // to disable OC functions for LT calling.

////////////////////////////////////////////////////////////////////////////////////
// Include your own header files here.


////////////////////////////////////////////////////////////////////////////////////
// Start your functions here.
void	import(string lpcszFileName)
{
	string strCmd;
	strCmd.Format("impcsv %s;", lpcszFileName);
	LT_execute(strCmd);
}


Hope it will help.

If there is any further problem, would you please send you sample Java code together with your sample project and CSV files to our Technique Support team, so we can do more checking.

You could follow the instructions below to send your file.
http://www.originlab.com/index.aspx?go=Support&pid=752



Best Regards.

Edited by - Sophy on 06/06/2012 11:15:02 PM
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000