• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

executable jar file

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
when i double click on jar file, I get error "Could not find the main class. Program will exit!" inspite of main class being defined in manifest. Any idea what I am missing?

Details:

'perfagent' is package in which Agent class is present

|***** Jar File content ****|
Agent$1.class
Agent.class
Manifest.mf

|**** Manifest File ****|
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.2
Created-By: 1.5.0-b64 (Sun Microsystems Inc.)
Main-Class: perfagent.Agent
X-COMMENT: Main-Class will be added automatically by build

|**** Agent class ****|
package perfagent;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class Agent extends JFrame {
JTextField tField1;
JTextField tField2;

/** Creates a new instance of Main */
public Agent() {
initComponents();
}

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here

Agent ag1 = new Agent();

}

private void initComponents() {
JPanel panel1 = new JPanel();
JButton button1 = new JButton("Continue");
JLabel label1 = new JLabel("Fahrenheit");
JLabel label2 = new JLabel("Celsius");
tField1 = new JTextField("Enter Temp in F");
tField2 = new JTextField("Temp in Celcius");
button1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
tField2.setText(String.valueOf((Float.valueOf(tField1.getText()) - 32)*5/9));
}
});
panel1.add(label1);
panel1.add(tField1);
panel1.add(label2);
panel1.add(tField2);
panel1.add(button1);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.getContentPane().add(panel1);
this.pack();
this.setVisible(true);
}

}
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,

when your class is in a package, the package directory structure must be inside the JAR as well.

so in your case this means that you must have directory structure something like this:

[ January 30, 2005: Message edited by: tanja klaut ]
 
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you run the jar file from the Dos prompt? If you can, then i suppose something is wrong with the runtime environment. If not, try running the jar without the package. I believe its got to be one of these two problems.
 
reply
    Bookmark Topic Watch Topic
  • New Topic