Note that there are some explanatory texts on larger screens.

plurals
  1. POadding jars to your program
    primarykey
    data
    text
    <p>i have a simple Demo.java file in <strong>D:\jarConcepts</strong> directory:</p> <pre><code>import javax.swing.* ; class Demo{ public static void main(String args[]){ JFrame frame = new JFrame("") ; frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE) ; Class c = null ; try{ c = Class.forName("com.mysql.jdbc.Driver") ; //com.mysql.jdbc.Driver class is in a jar file //whose class path is set in the environment variable(explicitly done by me) //when i am executing Demo.class using java command, it displays frame with OK title //but if i execute this by creating a jar, it enables to load the //com.mysql.jdbc.Driver class, //thus displaying frame with Sorry title frame.setTitle("OK") ; } catch(ClassNotFoundException cnfe){ frame.setTitle("Sorry") ; } frame.setVisible(true) ; } } </code></pre> <p><strong>I prepared a manifest.txt file in D:\jarConcepts with following text :</strong></p> <p>Main-Class: Demo</p> <p>Class-Path: C:\Program Files\MySQL\MySQL Tools for 5.0\java\lib\mysql-connector-java-5.0.4-bin.jar</p> <p><strong>when, i create a jar file from the same directory using</strong></p> <p>jar -cvfm Demo.jar manifest.txt .class</p> <p><strong>following is the output :</strong></p> <p>added manifest adding: Demo.class(in = 743) (out= 505)(deflated 32%)</p> <p><strong>But, when i execute the jar file generated, it shows an error message,</strong></p> <p>Could not find the main class. Program will exit.</p> <p><strong>i don't understand why this is happening, coz, when i creating the jar file with the following manifest code :</strong></p> <p>Main-Class: Demo</p> <p><strong>i am getting a perfectly executable Demo.jar, the only problem is that it is not loading the Driver class from the ] class path and when i am trying to add the path in the manifest, it's not working...... plz help.......</strong></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload