aspose file tools*
The moose likes Beginning Java and the fly likes Jar executable won't run when copied into desktop Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Jar executable won Watch "Jar executable won New topic
Author

Jar executable won't run when copied into desktop

Tariq Ahsan
Ranch Hand

Joined: Nov 03, 2003
Posts: 116
Hi,

I have a GUI application called 'GUI' which connects to a oracle database. I copied the classes12.jar for the JDBC connection from c:\oracle\ora92\jdbc\lib into my local directory c:\myfolder\java where I have my GUI application. I have the manifest file, 'manifest.txt' to have -

Main-Class: GUI<cr>
Class-Path: classes12.jar<cr>

From the DOS prompt I am doing -

C:\MyFolder\Java> jar mcf GUI.jar GUI*.class

Now double-clicking on GUI.jar executable from C:\MyFolder\Java works fine and gets connected to the database without any problem.

But when I copy the same GUI.jar into my desktop window and do the same I am only getting the first opening screen from my GUI but hangs when trying to connect to the database.

Also, if I copy the jar executable into another directory and try it run it from the command prompt I get the error as shown below -

C:\>java -jar GUI.jar
Error :
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver

I have tried to modify the Manifest.txt file several ways giving full path to the classes12.jar in the Class-Path and also directory path to the entry point in Main-Class. Nothing seems to work. One of the such way is like -

Main-Class: MyFolder.Java.GUI<cr>
Class-Path: C:/MyFolder/Java/classes12.jar

The contents in the jar is as follows -

C:\MyFolder\Java>jar tf GUI.jar
META-INF/
META-INF/MANIFEST.MF
GUI$1.class
GUI$ButtonHandler.class
GUI$CheckBoxListener.class
GUI$ComboBoxListener.class
GUI$MenuItemHandler.class
GUI$RadioListener.class
GUI$WindowEventHandler.class
GUI.class

Any idea what am I doing wrong?
Steven Bell
Ranch Hand

Joined: Dec 29, 2004
Posts: 1071
I'm not sure that the manifest file allows for absolute paths for the classpath. I think you have to put relative paths (have a lib directory, put classes12.jar in it and have lib/classes12.jar on the classpath line).

Of course you could put the classes12.jar in the same directory as the GUI jar and leave off the lib in the classpath.
Tariq Ahsan
Ranch Hand

Joined: Nov 03, 2003
Posts: 116
Thanks Steven for your reply. I was able to run the GUI.jar after copying it into desktop by making the following changes to the manifest.txt -

Main-Class: GUI<cr>
Class-Path: /oracle/ora92/jdbc/lib/classes12.jar<space>.<space><cr>
<empty line>

A separate question about this GUI.jar. Is there an easy way this could be copied into another PC where it has only the Oracle client installed? By installing Oracle client the PC has java, the path is C:\oracle\ora92\jdk\bin. The system PATH does not have this path set though.
Steven Bell
Ranch Hand

Joined: Dec 29, 2004
Posts: 1071
The jar file must be available on the classpath. I would not rely on where the oracle installation is, the user could easily have changed that(unless this is only being installed on one or two machines). You could include the jar as part of your install, force the user to have the same oracle installation path, or add the jar to the system classpath. There are other things you could do such as dynamic loading of the jar with a classloader, getting the path from the user or a properties file, but I'm not sure if that's necessary.

P.S. I'm guessing your manifest file worked because you have C:\ on your classpath. Might want to check that.
[ April 08, 2005: Message edited by: Steven Bell ]
Tariq Ahsan
Ranch Hand

Joined: Nov 03, 2003
Posts: 116
Given that all users who would be using this application already has the Oracle client installed on the same directory location as you mentioned. But strangely it is working for some users when the click on the jar. Others getting the window to select a program. I've looked at their system path and it looks like everyone has the jre setup from the oracle client installation the same way. This baffles me. Any idea?
Tariq Ahsan
Ranch Hand

Joined: Nov 03, 2003
Posts: 116
Given that all users who would be using this application already has the Oracle client installed on the same directory location as you mentioned. But strangely it is working for some users when the click on the jar. Others getting the window to select a program. I've looked at their system path and it looks like everyone has the jre setup from the oracle client installation the same way. This baffles me. Any idea?
Tariq Ahsan
Ranch Hand

Joined: Nov 03, 2003
Posts: 116
Sorry, double posted!
Steven Bell
Ranch Hand

Joined: Dec 29, 2004
Posts: 1071
If you get a window asking what program to use to open that jar, that means that javaw is not associated with jar files. You can do 'Open with...' and select javaw and check the 'always use...'. Should fix the problem. It's not a java thing, it's a windows thing. (most likely)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Jar executable won't run when copied into desktop