Yes, it's the classic classpath problem.
I'm trying to run a small application on Windows XP using the following for a batch file:
JavaHelpTest.class is indeed in the above directory, and jhall.jar is in the directory specified by the classpath argument. But I get the following output:
And jhall.jar does contain javax/help/JHelp.class
Below is the app:
What am I doing wrong?
Thanks.
I'm trying to run a small application on Windows XP using the following for a batch file:
Code:
echo off
cd D:\D_ProgramFiles\JavaHelp\MyStuff
java JavaHelpTest -classpath D:\D_ProgramFiles\JavaHelp\jh2.0\javahelp\lib\jhall.jar
pause
JavaHelpTest.class is indeed in the above directory, and jhall.jar is in the directory specified by the classpath argument. But I get the following output:
Code:
D:\D_ProgramFiles\JavaHelp\MyStuff>echo off
Exception in thread "main" java.lang.NoClassDefFoundError: javax/help/JHelp
Press any key to continue . . .
And jhall.jar does contain javax/help/JHelp.class
Below is the app:
Code:
// Import the javahelp files.
import javax.help.*;
import java.net.URL;
import javax.swing.*;
public class JavaHelpTest {
public static void main(String args[]) {
JHelp helpViewer = null;
try {
// Get the classloader of this class.
ClassLoader cl = JavaHelpTest.class.getClassLoader();
// Use the findHelpSet method of HelpSet to create a URL referencing the helpset file.
// Note that in this example the location of the helpset is implied as being in the same
// directory as the program by specifying "jhelpset.hs" without any directory prefix,
// this should be adjusted to suit the implementation.
URL url = HelpSet.findHelpSet(cl, "jhelpset.hs");
// Create a new JHelp object with a new HelpSet.
helpViewer = new JHelp(new HelpSet(cl, url));
// Set the initial entry point in the table of contents.
helpViewer.setCurrentID("Simple.Introduction");
} catch (Exception e) {
System.err.println("API Help Set not found");
}
// Create a new frame.
JFrame frame = new JFrame();
// Set it's size.
frame.setSize(500,500);
// Add the created helpViewer to it.
frame.getContentPane().add(helpViewer);
// Set a default close operation.
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
// Make the frame visible.
frame.setVisible(true);
}
}
What am I doing wrong?
Thanks.