Package com.guan.code20160405;
Import Java.io.File;
Import java.io.IOException;
public class Openhelpfile {
public static void Main (string[] args) {
/**
* I put Gobang document 1.0.chm under the ProjectFile folder in the same directory as the project
*/
String ch1= "/";
String ch2= "//";
Find the root path of the project
String ContextPath = System.getproperty ("User.dir");
File File=new file (contextpath);
String p = file.getparent ();
File = new file (p + "/projectfile");
System.out.println ("path====" +file.getpath ());
System.out.println ("parent===" +file.getparent ());
String helpFilePath = p + "/projectfile/Gobang document 1.0.chm";
try {
Hh.exe is a program that allows CHM files in Windows systems
Runtime.getruntime (). EXEC ("hh.exe" +helpfilepath.replaceall (CH1,CH2));
} catch (IOException e) {
TODO auto-generated Catch block
E.printstacktrace ();
}
}
}
Run, open the "Gobang document 1.0.chm" file successfully.
To open a CHM-formatted help document using Java code