main class not found
i want to develop jar file of my application..
i have set the main class of jar file in Manifest.txt file
I have created a jar file using command:
jar cf Bluetooth.jar Manifest.txt javaapplication10.Bluetooth.class
(javaapplication10) is the name of package..
after this when i try to execute the jar file using command:
>>java -jar Bluetooth.jar
it is throwing the exception as:
please let me know what is problem with this.
is i'm missing any step of jar creation?
quite possibly the class you have placed into the jar file has a dependency on another class that is not included into the jar file.
For example, if I create a jar file that depends on the commons-logging or log4j (has a local reference to the logger component) then my classpath needs to include those third party jar files.
For the jar to run with java -jar, in addition to specifying the Main-Class attribute, you can also set a Class-Path attribute, which should be a relative path to the location of the other dependent jar files.
See also: Adding Classes to the JAR File's Classpath (The Java™ Tutorials > Deployment > Packaging Programs in JAR Files)
Thank u very much 4 ur help.
but i'm still having the same problem.
Now I'm having two text files viz., Manifest.txt and Manifest1.txt
contents of Manifest.txt are:
contents of Manifest1.txt are:
Class-Path: avetanaObex.jar bluecove.jar BlueCoveJSR82.jar
now i've created the jar file using the following command
jar cfv blue.jar Manifest.txt Manifest1.txt BluetoothServiceDiscovery.class
it is creating the jar file properly.by giving the following o/p on command prompt:
adding: Manifest.txt(in = 59) (out= 46)(deflated 22%)
adding: Manifest1.txt(in = 60) (out= 54)(deflated 10%)
adding: BluetoothServiceDiscovery.class(in = 11342) (out= 5852)(deflated 48%)
but when i try to run the blue.jar file using following command:
java -jar blue.jar
it's showing the same error:
Failed to load Main-Class manifest attribute from blue.jar
Please let me know what is problem?
Hi , thank u again 4ur concern.
I got the solution for the same problem ,
now my application is working properly.