Page 1 of 1

Using iMacros with JAVA (via the Jawin package) in Eclipse

Posted: Tue Feb 13, 2007 1:46 pm
by Hannes, Tech Support
[Update 2010-08-23]
The Jawin library does not support 64bit. However, there's a replacement called JACOB (http://sourceforge.net/projects/jacob-project/). It's pretty easy to use and the main steps given below still hold. Just replace any reference to jawin with the appropriate JACOB one. Additionally, I have posted a small HowTo here.
[End of update]

[Update]
When running iMacros from Java, you may also be interested in using the iMacros Java wrapper class: http://forum.iopus.com/viewtopic.php?f=14&t=1147
[End of update]

[update]
A tutorial for using NetBeans instead of Eclipse can be found here: http://forum.iopus.com/viewtopic.php?f=6&t=7183
[End of update]



Preliminaries:

1) Download Jawin (http://jawinproject.sourceforge.net/, version 1.0.19, released under this license: http://jawinproject.sourceforge.net/LICENSE.txt), extract to local folder
[Update] Version 2.0-alpha1 also works fine.[End of update]

2) Start Eclipse

Start new project (usign jawin) in Eclipse:

1) File --> New --> Project

Image

2) Java --> Java Project --> Next

Image

3) Enter name: "iMacrosScriptingInterface" --> Next

4) Libraries --> Add External Jars" --> select jawin.jar from the Jawin\lib directory --> Finish

Image

5) Right-click iMacrosScriptingInterface in Package Explorer tab

Image

6) Import --> General --> File System --> Next

Image

7) Browse --> jawin-dir\bin\jawin.dll --> Finish

New Class in project

1) Select iMacrosScriptingInterface in the Package Explorer tab

2) File --> New --> Class

Image

3) Name: iMacrosTest --> Finish

Writing/Runnign an example

1) Open iMacrosTest.java

2) Copy the following code to iMacrosTest.java:

Code: Select all

//This code makes use of jawin from http://jawinproject.sourceforge.net/
//jawin license: http://jawinproject.sourceforge.net/LICENSE.txt

//two imports from jawin.jar
import org.jawin.DispatchPtr;
import org.jawin.win32.Ole32;

public class iMacrosTest {

	public static void main(String[] args) {
		try {
			Ole32.CoInitialize();

			DispatchPtr app = new DispatchPtr("imacros");

			//Calling iMacros methods
			app.invoke("iimInit", null);
			app.invoke("iimPlay", "CODE:URL GOTO=http://www.iopus.com");
			app.invoke("iimPlay", "CODE:TAG POS=1 TYPE=A ATTR=TXT:iMacros EXTRACT=TXT");

			//manually cast return values to correct type
			String iret = app.invoke("iimGetLastExtract").toString();

			app.invoke("iimExit");
                        System.out.println(iret);
                       
			Ole32.CoUninitialize();
		}

		catch (Exception e){
			e.printStackTrace();
		}

	}
}
[Edit: changed "URL GOTO=www.iopus.com" to "URL GOTO=http://www.iopus.com]
[Update]Changed TAG command to comply with web page layout.[End of update]

3) You might want to select the full code and have it automatically be indented with "CTRL-i"

4) Menu: Run --> Run...

Image

5) Rightclick Java-Application --> New

Image

6) Under "Classpath" you should find the jawin.jar

Image

7) Under "Common" check both Debug and Run

Image

8) Click Run
this can later be accessed by the Run-Button:

Image

The Java class will now be compiled and started. It will open an iMacros browser window that visits http://www.iopus.com

Re: Using iMacros with JAVA (via the Jawin package) in Eclipse

Posted: Tue Mar 18, 2008 12:59 am
by killer_mpg
Does this work with linux?

Re: Using iMacros with JAVA (via the Jawin package) in Eclipse

Posted: Tue Apr 29, 2008 9:46 am
by Hannes, Tech Support
For Firefox, you can use the JavaScript Scripting Interface: http://wiki.imacros.net/iMacros_for_Fir ... _Interface

Files

Posted: Fri May 02, 2008 10:30 am
by Hannes, Tech Support
The attached ZIP contains the full Eclipse workspace folder for the project.
(You may probably need to adjust the paths.)

Re: Using iMacros with JAVA (via the Jawin package) in Eclipse

Posted: Mon Jun 30, 2008 8:21 pm
by sothy1962
Silly question, but is the expectation that one builds the jawin.jar file as it was not in the download?

Re: Using iMacros with JAVA (via the Jawin package) in Eclipse

Posted: Tue Jul 01, 2008 6:54 am
by Hannes, Tech Support
If you download the binary 1.0.19 (jawin-1.0.19.zip, you will probably need to scroll down on that page), you will find the "jawin.jar" in "jawin-1.0.19/lib".

Re: Using iMacros with JAVA (via the Jawin package) in Eclipse

Posted: Mon Dec 01, 2008 7:00 pm
by talz13
Is there any way to use full java scripting under linux? Jawin is only for windows as far as I can see. I found j-interop on google, but don't know if that can take the place of jawin.

Re: Using iMacros with JAVA (via the Jawin package) in Eclipse

Posted: Mon Dec 01, 2008 10:17 pm
by Tech Support
Currently, the iMacros Scripting Interface works only on Windows OS, however you can use popular "Linux" languages such as Perl, Python, PHP or Ruby to script it on Windows. Of course, iMacros also runs well on a virtual machine that you can host on your Linux server.

We plan to release a native Linux version in 2009. If you are interested in beta-testing such a version please email info AT iopus.com and we will notify you once the first beta is available.

Last but not least, you can already use iMacros for Firefox on Linux and control the browser via the command line interface:
http://wiki.imacros.net/iMacros_for_Fir ... ne_Support

Re: Using iMacros with JAVA (via the Jawin package) in Eclipse

Posted: Mon Apr 27, 2009 6:07 pm
by Hannes, Tech Support
Please cf. the answer above.

Re: Using iMacros with JAVA (via the Jawin package) in Eclipse

Posted: Mon Jul 13, 2009 7:50 am
by srinivas
Hi , I used the same code to test.I follow the same steps what it was mentioned in the above.But it was not working. I got the output as VT_BSTR .
can any one tell me the solution.

Re: Using iMacros with JAVA (via the Jawin package) in Eclipse

Posted: Mon Jul 13, 2009 1:13 pm
by Hannes, Tech Support

Re: Using iMacros with JAVA (via the Jawin package) in Eclipse

Posted: Tue Sep 08, 2009 11:38 am
by richermartyn
Thank you for providing a information about Eclipse and I have download this url and I have installed in my system I follow such steps which you given over here. It's working Properly.

Running from the command line

Posted: Tue Aug 17, 2010 11:31 am
by Hannes, Tech Support
When run from the command line, both locations of the jawin library/binary (jawin.jar and the folder of jawin.dll) must be given in "classpath" and "java.library.path", respectively.

Given that both, the eclipse project and the jawin folder reside in c:\users\name\eclipse.workspace, here's how the command line calling "DownloadTest.class" looks like:

Code: Select all

C:\Users\name\eclipse.workspace\iMacrosJavaDownloadTest\bin>java -classpath C:\Users\name\eclipse.workspace\iMacrosJavaDownloadTest\bin;C:\Users\name\eclipse.workspace\iMacrosJavaDownloadTest\res\jawin-2.0-alpha1\lib\jawin.jar -Djava.library.path=c:\users\name\eclipse.workspace\jawin-2.0-alpha1\bin DownloadTest

Re: Using iMacros with JAVA (via the Jawin package) in Eclip

Posted: Mon Aug 23, 2010 8:40 am
by Hannes, Tech Support
The Jawin library does not support 64bit. However, there's a replacement called JACOB (http://sourceforge.net/projects/jacob-project/). It's pretty easy to use and the main steps given in the initial post still hold. Just replace any reference to jawin with the appropriate JACOB one. Additionally, I have posted a small HowTo here.