Monday, May 24, 2010

How can I create and manipulate an application object using Java in UNIX?

Yes, big question, but I really am looking for the UNIX equivalent of a Windows JScript that does the following (for example only, I realized I can't call a Microsoft application on UNIX)....





var objwd=new ActiveXObject("word.application");


objwd.visible=false;


objwd.Documents.open("blah");





...





Again, obviously the example above is a Windows-application specific example only. What I'm looking to do is merely emulate a similar concept except using Java (or Perl would be fine too, but I have so little knowledge of either). I want to create an object reference to a particular UNIX-installed application and then manipulate the object with the permissible methods associated with that object. I'm fairly familiar with the way to do this in Windows Scripting, but am quite new to UNIX and am trying to learn the various analygous scripting methods there. Any help (especially code samples) would be much appreciated.

How can I create and manipulate an application object using Java in UNIX?
Well first off, you don't really have COM (you can get emulators) on UNIX systems so you need to work directly with the applications and their APIs to interact with them. If you are looking to do this from Java, you would create your application using the jar file containing APIs from the application you are trying to launch. You could also see if a command line version exist for simple things like trying to open an executable, like "/opt/myapp/app.exe somefile.txt".





For many of the scripting tasks, you can generally find good examples in /etc/rc2.d for starting up applications (similar to what Microsoft services does but without the complexity of actually registering a service...you can just create a startup script and place it in there with a start number for sequence). Of course if you are running a UNIX system like Solaris 10, you do get Service Management Framework (SMF) that offers the features of dependencies and parallel start. I'm not sure if any of the Linux distros have a similar capability or not.





** Edit **


Are you looking to do this for a particular application then? I have plenty of Solaris experience going from Sun OpenWindows 4.x and Solaris 2.5 through Solaris 10. For better or worse (depends who you ask), you won't find VBA like references available on Solaris.


No comments:

Post a Comment