Results 1 to 6 of 6
- 08-18-2010, 09:58 AM #1
Member
- Join Date
- Aug 2010
- Posts
- 2
- Rep Power
- 0
How to embed a .chm file in Executable jar file
hi,
I integrated a help file into to particular pacakage through IDE As Swings Application,and when executing the jar file following code identifies the particular .chm file at Runtime.
public static List getClasseNamesInPackage(String jarName, String packageName)
{
ArrayList arrayList = new ArrayList ();
packageName = packageName.replaceAll("\\." , "/");
if (getJar)
System.out.println("Jar " + jarName + " for " + packageName);
try{
JarInputStream jarFile = new JarInputStream(new FileInputStream (jarName));
JarEntry jarEntry;
while(true) {
jarEntry=jarFile.getNextJarEntry ();
if(jarEntry == null){
break;
}
if((jarEntry.getName ().startsWith (packageName)) && (jarEntry.getName ().endsWith (".chm")) ) {
String name=jarEntry.getName().toString();
System.out.println("name:"+name);
// java.lang.Runtime.getRuntime().exec("rundll32 SHELL32.DLL,ShellExec_RunDLL "+executionPath+"/Prototype.jar!/"+jarEntry.getName());
java.lang.Runtime.getRuntime().exec("rundll32 SHELL32.DLL,ShellExec_RunDLL "+"c:\\dist\\Prototype\\Super_Home\\help\\helpfile .chm");
but, the problem is i can't access the .chm file at the runtime while executing the jar file itself, and i am getting null pointer exception. how to solve this problem.pls...urgent
- 08-18-2010, 01:20 PM #2
Can you show the error message with its source line number indicating where the NPE occurs?i can't access the .chm file at the runtime
These statements look like the code will exit the while loop when jarEntry IS NULLJava Code:if(jarEntry == null){ break; } if((jarEntry.getName ()
causing a NPE when the getName() method is called.
- 08-18-2010, 06:36 PM #3
Once the .CHM is inside the jar it isn't a file. If you need to launch it, you'll have to extract it first and write it to the filesystem.I integrated a help file into to particular pacakage through IDE As Swings Application,and when executing the jar file following code identifies the particular .chm file at Runtime.
db
- 08-23-2010, 01:10 PM #4
Member
- Join Date
- Aug 2010
- Posts
- 2
- Rep Power
- 0
hi,
Burke and norm Thank you for your great support.I am able to findout the .chm file name only at runtime through the following code.
String name=jarEntry.getName().toString();
System.out.println("name:"+name);
But,the requirement is open that file at runtime when user action performed i write the following code.At runtime can't we open the file as .chm without extracting the jar file?..i need to be deploy like a jar file only at client machine.
i am new to using .chm help file, how to give a file path as file system at runtime jar execution?.....
if((jarEntry.getName ().startsWith (packageName)) && (jarEntry.getName ().endsWith (".chm")) ) {
String name=jarEntry.getName().toString();
System.out.println("name:"+name);
String executionPath = System.getProperty("user.dir");
java.lang.Runtime.getRuntime().exec("rundll32 SHELL32.DLL,ShellExec_RunDLL "+executionPath+"/"+jarEntry.getName());
}
Thank you,
vijay
- 08-23-2010, 11:31 PM #5
Did you see this from Darryl.Burke:
You'll have to open an output file and copy the .chm jarEntry to the file before issuing the exec() method call.Once the .CHM is inside the jar it isn't a file. If you need to launch it, you'll have to extract it first and write it to the filesystem.
- 08-24-2010, 07:15 AM #6
Similar Threads
-
Executable File.
By BeeGee in forum Advanced JavaReplies: 13Last Post: 05-25-2010, 12:35 PM -
Exporting to a executable JAR file
By Drun in forum EclipseReplies: 4Last Post: 03-27-2010, 03:16 PM -
how to embed .jar in an html or php file
By clydedoris in forum AWT / SwingReplies: 0Last Post: 03-10-2010, 06:00 AM -
Executable Jar File Creation
By Doctor Cactus in forum New To JavaReplies: 7Last Post: 11-13-2008, 03:31 AM -
Generate an executable file
By romina in forum New To JavaReplies: 1Last Post: 08-07-2007, 05:30 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks