Could not find the main class: .... Program will exit.

  • (2 Pages)
  • +
  • 1
  • 2

22 Replies - 13097 Views - Last Post: 10 March 2012 - 05:42 PM Rate Topic: -----

#1 carnivroar  Icon User is offline

  • D.I.C Regular

Reputation: 28
  • View blog
  • Posts: 384
  • Joined: 18-September 11

Could not find the main class: .... Program will exit.

Posted 09 March 2012 - 08:56 PM

I'm getting this error whenever I try to created a runnable jar file with Eclipse. It was working fine just a few days ago. What's going on?
Is This A Good Question/Topic? 0
  • +

Replies To: Could not find the main class: .... Program will exit.

#2 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8346
  • View blog
  • Posts: 31,908
  • Joined: 06-March 08

Re: Could not find the main class: .... Program will exit.

Posted 09 March 2012 - 09:16 PM

Show us your manifest file... and honestly even if I use Eclipse for more than 10 years I rely on that link to build my JAR
http://docs.oracle.c...asicsindex.html
Was This Post Helpful? 0
  • +
  • -

#3 carnivroar  Icon User is offline

  • D.I.C Regular

Reputation: 28
  • View blog
  • Posts: 384
  • Joined: 18-September 11

Re: Could not find the main class: .... Program will exit.

Posted 09 March 2012 - 09:18 PM

Manifest-Version: 1.0
Class-Path: .
Main-Class: resistance.ResistorsFrame


I think it's something wrong with my computer because I had some other runnable jar files that were running just a few weeks ago, and now they too give me the same problem.

I uploaded the jar file if you want to try running it yourself:

https://sites.google.../resistance.jar
Was This Post Helpful? 0
  • +
  • -

#4 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8346
  • View blog
  • Posts: 31,908
  • Joined: 06-March 08

Re: Could not find the main class: .... Program will exit.

Posted 09 March 2012 - 09:29 PM

Downloaded your .jar
It does not have a manifest file... a leat not at the top level
Was This Post Helpful? 0
  • +
  • -

#5 carnivroar  Icon User is offline

  • D.I.C Regular

Reputation: 28
  • View blog
  • Posts: 384
  • Joined: 18-September 11

Re: Could not find the main class: .... Program will exit.

Posted 09 March 2012 - 09:32 PM

View Postpbl, on 09 March 2012 - 09:29 PM, said:

Downloaded your .jar
It does not have a manifest file... a leat not at the top level


It's there when I open it with 7-zip. Under a folder called META-INF.
Was This Post Helpful? 0
  • +
  • -

#6 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8346
  • View blog
  • Posts: 31,908
  • Joined: 06-March 08

Re: Could not find the main class: .... Program will exit.

Posted 09 March 2012 - 09:38 PM

Yes here it is

Manifest-Version: 1.0
Class-Path: .
Main-Class: resistance.ResistorsFrame
Was This Post Helpful? 0
  • +
  • -

#7 carnivroar  Icon User is offline

  • D.I.C Regular

Reputation: 28
  • View blog
  • Posts: 384
  • Joined: 18-September 11

Re: Could not find the main class: .... Program will exit.

Posted 09 March 2012 - 09:40 PM

View Postpbl, on 09 March 2012 - 09:38 PM, said:

Yes here it is

Manifest-Version: 1.0
Class-Path: .
Main-Class: resistance.ResistorsFrame


Yes.... so how come it's not running?
Was This Post Helpful? 0
  • +
  • -

#8 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8346
  • View blog
  • Posts: 31,908
  • Joined: 06-March 08

Re: Could not find the main class: .... Program will exit.

Posted 09 March 2012 - 09:43 PM

And your ResitorFrame class has a main() method ?
Was This Post Helpful? 0
  • +
  • -

#9 carnivroar  Icon User is offline

  • D.I.C Regular

Reputation: 28
  • View blog
  • Posts: 384
  • Joined: 18-September 11

Re: Could not find the main class: .... Program will exit.

Posted 09 March 2012 - 09:48 PM

View Postpbl, on 09 March 2012 - 09:43 PM, said:

And your ResitorFrame class has a main() method ?


Yes, it does. It runs fine on Eclipse.

This post has been edited by carnivroar: 09 March 2012 - 09:52 PM

Was This Post Helpful? 0
  • +
  • -

#10 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8346
  • View blog
  • Posts: 31,908
  • Joined: 06-March 08

Re: Could not find the main class: .... Program will exit.

Posted 09 March 2012 - 10:04 PM

Yes :) Here it is

    public static void main(String args[])
    {
        Resistors r = new Resistors();
        JFrame window = new JFrame("Resistance Calculator");
        window.setSize(200, 250);
        r.init();
        window.setResizable(false);
        window.setContentPane(r);
        window.setDefaultCloseOperation(3);
        window.setVisible(true);
    }
}


And it is in the good package

package resistance;

that matches the .mf file

Main-Class: resistance.ResistorsFrame

I am puzzled

View Postcarnivroar, on 09 March 2012 - 10:56 PM, said:

I'm getting this error whenever I try to created a runnable jar file with Eclipse. It was working fine just a few days ago. What's going on?

Actually, which error ? You haven't post it
Was This Post Helpful? 0
  • +
  • -

#11 carnivroar  Icon User is offline

  • D.I.C Regular

Reputation: 28
  • View blog
  • Posts: 384
  • Joined: 18-September 11

Re: Could not find the main class: .... Program will exit.

Posted 09 March 2012 - 10:07 PM

Quote

View Postcarnivroar, on 09 March 2012 - 10:56 PM, said:

I'm getting this error whenever I try to created a runnable jar file with Eclipse. It was working fine just a few days ago. What's going on?

Actually, which error ? You haven't post it


The one in the title.

Double click on jar file, window pops up:

Java Virtual Machine Launcher

Could not find the main class: resistance.ResistorsFrame. Program will exit.

This post has been edited by carnivroar: 09 March 2012 - 10:08 PM

Was This Post Helpful? 0
  • +
  • -

#12 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8346
  • View blog
  • Posts: 31,908
  • Joined: 06-March 08

Re: Could not find the main class: .... Program will exit.

Posted 09 March 2012 - 11:05 PM

Sorry, don;t see why it wouldn't work
Is the JRE versionb on the targer host equals or is higher than the JDK version of the host where the code was compiled ?
Actually, got the same error when I double click your .jar on my PC
Was This Post Helpful? 0
  • +
  • -

#13 carnivroar  Icon User is offline

  • D.I.C Regular

Reputation: 28
  • View blog
  • Posts: 384
  • Joined: 18-September 11

Re: Could not find the main class: .... Program will exit.

Posted 09 March 2012 - 11:34 PM

I'll try making a jar from another computer tomorrow then. Thanks for trying to help though.
Was This Post Helpful? 0
  • +
  • -

#14 carnivroar  Icon User is offline

  • D.I.C Regular

Reputation: 28
  • View blog
  • Posts: 384
  • Joined: 18-September 11

Re: Could not find the main class: .... Program will exit.

Posted 10 March 2012 - 10:23 AM

Made a jar using my mom's computer and it works fine. But the jar file still does not run on mine. It's something wrong with my machine's setup. Any idea?
Was This Post Helpful? 0
  • +
  • -

#15 carnivroar  Icon User is offline

  • D.I.C Regular

Reputation: 28
  • View blog
  • Posts: 384
  • Joined: 18-September 11

Re: Could not find the main class: .... Program will exit.

Posted 10 March 2012 - 12:44 PM

Something was wrong with my java installations. So I manually deleted everything and copied a java folder from an old hard drive. Works fine now. I have no idea what happened.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2