Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 305
  • Last Modified:

Opening Altova Authentic with filename as parameter

Hi Experts,

I would like to open Altova Authentic from my JBuilder Java application. Altova Authentic is a software tool that enables me to view the xml file's data.

I have an xml file name stored in a variable.

For example: String x = "newNodes.xml"

I would like to open Altova Authentic using this string variable. I have seen previous sample code such as:

Runtime.getRunTime().exec(start ("yourdocument.doc"));

I presume the '.doc' is what opens the word document, however, with a '.xml' extension, it is obvious the Windows environment is not sure what program to open the filename with. This is where my problem lies.

Any help much appreciated!

0
dev-ngps7
Asked:
dev-ngps7
  • 11
  • 6
1 Solution
 
TimYatesCommented:
Runtime.getRuntime().exec( "start C:\\Progra~1\\altova.exe C:\\newNodes.xml" );

should do it...

you may need to read inputstream if the program spits out any text...

0
 
TimYatesCommented:
and assuming you are on windows...

Change "C:\\Progra~1\\altova.exe" to the actual path of the "Altova Authentic" executable

and change "C:\\newNodes.xml" to the actual path of your XML file...
0
 
dev-ngps7Author Commented:
import java.lang.Runtime;

// absoluteFilename is string containing location of xml file

Runtime.getRuntime().exec( "start C:/Program Files/Altova/Authentic2005/" + absoluteFileName);

Errors as you said it might,

"java.io.IOException: CreateProcess: start C:/Program Files/Altova/Authentic2005/D:\KnowledgeBaseProject2\Knowledgebase/Content/kb00007.xml error=2 caught; Class: DataHandler, Method: processEntryNode"

Doesn't mean much to me though :o(
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
TimYatesCommented:
errr...  you will need to use Windows slashes (like I did), and include the filename for the application (like I did)

Runtime.getRuntime().exec( "start C:\\Progra~1\\Altova\\Authentic2005\\Authentic.exe " + absoluteFileName ) ;

or something...
0
 
dev-ngps7Author Commented:
All to no avail................

Runtime.getRuntime().exec( "start C:\\Progra~1\\Altova\\Authentic2005\\authentic.exe " + "/" + absoluteFileName);

Runtime.getRuntime().exec( "start C:\\Progra~1\\Altova\\Authentic2005\\AUTHENTIC.exe " + "/" + absoluteFileName);

Runtime.getRuntime().exec( "start C:\\Program Files\\Altova\\Authentic2005\\authentic.exe" + "/" + absoluteFileName);

Runtime.getRuntime().exec("C:\\Progra~1\\Altova\\Authentic2005\\AUTHENTIC.exe" + "/" + absoluteFileName);

Runtime.getRuntime().exec("C:\\Program Files\\Altova\\Authentic2005\\authentic.exe" + "/" + absoluteFileName);

0
 
TimYatesCommented:
Runtime.getRuntime().exec( "start C:\\Progra~1\\Altova\\Authentic2005\\authentic.exe " + absoluteFileName);

what is absoluteFileName?
0
 
TimYatesCommented:
Actually, try:

    Runtime.getRuntime().exec( "cmd /c start \"C:\\Progra~1\\Altova\\Authentic2005\\authentic.exe\" \"" + absoluteFileName + "\"" ) ;

make sure absoluteFileName has windows style slashes, etc...
0
 
TimYatesCommented:
Or, try:

    Runtime.getRuntime().exec( "cmd /c start \"C:\\Program Files\\Altova\\Authentic2005\\authentic.exe\" \"" + absoluteFileName + "\"" ) ;
0
 
TimYatesCommented:
is the program called "authentic.exe"?
0
 
dev-ngps7Author Commented:
Its called AUTHENTIC.exe but the following works below

Runtime.getRuntime().exec("C:\\Progra~1\\Altova\\Authentic2005\\authentic.exe"

This opens Authentic but when i add my filename string it errors

hmmmm, the filename is correct i have triple checked, strange.....
0
 
TimYatesCommented:
>> hmmmm, the filename is correct i have triple checked, strange.....

what is it?  Can you paste it here?
0
 
dev-ngps7Author Commented:
Sure,

D:\KnowledgeBaseProject2\Knowledgebase/Content/kb00002.xml


Tim, your last suggestion opened the xml file in explorer (my default browser) but not with Altova!

Runtime.getRuntime().exec( "cmd /c start \"C:\\Program Files\\Altova\\Authentic2005\\authentic.exe\" \"" + absoluteFileName + "\"" ) ;

So now i can open Altova with no xml file OR open the xml file with no Altova, nearly!!


0
 
TimYatesCommented:
>> D:\KnowledgeBaseProject2\Knowledgebase/Content/kb00002.xml

Try doing:

absoluteFileName = "D:\\KnowledgeBaseProject2\\Knowledgebase\\Content\\kb00002.xml" ;
Runtime.getRuntime().exec( "cmd /c start \"C:\\Program Files\\Altova\\Authentic2005\\authentic.exe\" \"" + absoluteFileName + "\"" ) ;
0
 
dev-ngps7Author Commented:
Tried that and another idea, both listed below, only shows xml file in explorer still

absoluteFileName = "D:\\KnowledgeBaseProject2\\Knowledgebase\\Content\\" + getNewFileName();

absoluteFileName = "D:/KnowledgeBaseProject2/Knowledgebase/Content/" + getNewFileName();

// run twice using both code snippets above

Runtime.getRuntime().exec( "cmd /c start \"C:\\Program Files\\Altova\\Authentic2005\\authentic.exe\" \"" + absoluteFileName + "\"" ) ;
0
 
TimYatesCommented:
Ok... try:

// This is correct...  as it has to be in Windows format
absoluteFileName = "D:\\KnowledgeBaseProject2\\Knowledgebase\\Content\\" + getNewFileName();
Runtime.getRuntime().exec( "C:\\Progra~1\\Altova\\Authentic2005\\authentic.exe " + absoluteFileName ) ;
0
 
dev-ngps7Author Commented:
WOW! Cheers TimYates, i think between us there were about 20 combinations tried, but we got there in the end!

Thanx :)
0
 
TimYatesCommented:
hehehe :-)

Glad we got it sorted in the end!!  Soz it wasn't quicker, but I can't test it at my end as I'm on linux :-(

Yay!

Good luck with it all!! :-)

Tim
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 11
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now