File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Program works fine in IDE, but not in JAR. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Program works fine in IDE, but not in JAR." Watch "Program works fine in IDE, but not in JAR." New topic
Author

Program works fine in IDE, but not in JAR.

Tarek Khojah
Ranch Hand

Joined: Jul 21, 2007
Posts: 58
I remember I had this problem when it came to files, where I had to use getResourceAsStream()

Now I'm facing the same problem with:

Class.forName("org.hsqldb.jdbcDriver");

Throwing a class not found exception.

I have no clue on what to do, please help.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8707
    
    6

You have a dependency on HSQLDB. Your IDE is resolving it for you, but you also have to tell your JAR how to resolve it.
The Java Tutorial chapter on JAR files has a section on how to set the classpath.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Tarek Khojah
Ranch Hand

Joined: Jul 21, 2007
Posts: 58
I'm surprised that Eclipse doesn't take care of these things for you.

Heh, it probably does and I just don't know how.

Thank you for your help, very much appreciated
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Program works fine in IDE, but not in JAR.
 
Similar Threads
problem in uploading assignment
WSAD Workspace. Problem with switching them
Java and C# encoding prob
how to delete .tmp file in server which is created during file upload
Help with parameters for JOptionPane.showMessageDialog