Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / September 2007

Tip: Looking for answers? Try searching our database.

Could not find Main Class while executing JAR

Thread view: 
Grzesiek - 09 Sep 2007 11:01 GMT
When i double -click my jar file in dist folder everything is ok, but
when i copy it to another folder and then i double click it again i
get message box:
"Could not find the main class. Program will exit"

Here is my manifest file:

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.5
Created-By: 1.6.0_01-b06 (Sun Microsystems Inc.)
Main-Class: myPackage.MyClass
Class-Path: lib/log4j-1.2.14.jar
X-COMMENT: Main-Class will be added automatically by build

The problem started when i added lib/log4j-1.2.14.jar  to Class-Path.
What can i do?

Thanx
Lars Enderin - 09 Sep 2007 11:34 GMT
Grzesiek skrev:
> When i double -click my jar file in dist folder everything is ok, but
> when i copy it to another folder and then i double click it again i
[quoted text clipped - 12 lines]
> The problem started when i added lib/log4j-1.2.14.jar  to Class-Path.
> What can i do?

You have to include the full path of the jar file to Class-Path, if you
refer to it outside the dist folder.
Grzesiek - 09 Sep 2007 12:38 GMT
> Grzesiek skrev:
>
[quoted text clipped - 19 lines]
>
> - Poka  cytowany tekst -

Txanx Lars the problem was that lib/log4j-1.2.14.jar was not found
Lew - 09 Sep 2007 13:30 GMT
Lars Enderin wrote:
>> You have to include the full path of the jar file to Class-Path, if you
>> refer to it outside the dist folder.

According to
<http://java.sun.com/docs/books/tutorial/deployment/jar/downman.html>
that is not true.  Relative paths work just fine.

Signature

Lew

Lars Enderin - 09 Sep 2007 23:35 GMT
Lew skrev:
> Lars Enderin wrote:
>>> You have to include the full path of the jar file to Class-Path, if you
[quoted text clipped - 3 lines]
> <http://java.sun.com/docs/books/tutorial/deployment/jar/downman.html>
> that is not true.  Relative paths work just fine.

Ok, but relative to what? He copied the program to a place outside the
dist folder, but did not copy the dist/lib/log4j* jar file to the same
place, apparently.
Lew - 10 Sep 2007 01:12 GMT
> Lew skrev:
>> Lars Enderin wrote:
[quoted text clipped - 8 lines]
> dist folder, but did not copy the dist/lib/log4j* jar file to the same
> place, apparently.

What is the "dist" folder?

The provided link explains it all, if you follow it.
> Note : The Class-Path header points to classes or JAR files on the local network

In other words, relative to the directory in which the application JAR is
installed.

From the same link:
> An Example
>
[quoted text clipped - 3 lines]
>
>     Class-Path: MyUtils.jar

Signature

Lew



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.