Click here to Skip to main content
15,121,030 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
I want to open a CHM (help) file from my java application...
My code looks like that:
Runtime.getRuntime().exec("hh.exe myhelpfile.chm");

It works, but how can i open it with a specific page??

Thanks,
Tom :)
Posted
Updated 4-Mar-11 14:29pm
v2
Comments
Dalek Dave 4-Mar-11 19:29pm
   
Edited for code block and readability.

I was actually able to get this to work successfully based on tvizel88's comment; the critical problem is that the HTML is not usually cached in the CHM file in /the/full/path/form.
If you do as he suggests, but using the topic ID specified in the help creation software, that should work better (at least it did for me).
If you are having trouble, do as Richard MacCutchan suggests and try it from the command line, to take Java out of the equation.
This worked fine for me:
hh.exe UserManual.chm::/Using_This_Help_System.htm
I am using Help & Manual 5 to produce the CHM file, and Using_This_Help_System shows up as the topic ID, even though it is actually embedded a couple layers down in my table of contents. I was initially trying to include the full path implied by the TOC, and that didn't work at all.
   
You'd need to read the docs to find out if you can specify a page from the command line. Java plainly has no idea what it is doing, it's just passing on a run command.
   
I have found something like that:
Runtime.getRuntime().exec("hh.exe myhelpfile.chm::/path/to/my/page.htm");


but it doesn't work for me.
Is there no solution for that problem in java?
   
v2
Comments
Richard MacCutchan 18-Aug-10 5:09am
   
This is not a Java problem. You need to make sure that your command "hh.exe ..." is correctly formatted and includes the required options. Try typing it in a command window to make sure it works.
It is simple solution

String fileName = "C:\\Users\\Riyasam\\Documents\\NetBeansProjects\\Student Project\\src\\studentproject\\resources\\RealWorld.chm";
String[] commands = {"cmd", "/c", fileName};
try {
Runtime.getRuntime().exec(commands);
//Runtime.getRuntime().exec("C:\\Users\\Riyasam\\Documents\\NetBeansProjects\\SwingTest\\src\\Test\\RealWorld.chm");
} catch (Exception ex) {
ex.printStackTrace();
}

enjoying from now.. :P
   
Comments
raj100mac 8-Apr-13 2:03am
   
Sir i made a rpoject using java and eclipse.and i also made a .chm help file.sir i want to attach this .chm file to my java project.plz give me the complete format of code.including details of coding.plz help me.
raj100mac 8-Apr-13 2:04am
   
from the above code which type of file i have to made.like class,jsp,wwhat and how to use them.help me immediatly,

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900