Jump to content
xisto Community
Sign in to follow this  
hippiman

Eclipse Exporting .jar Files Could not find main class. Program will exit.

Recommended Posts

I need help!I've been using eclipse for a while making little applets, and now I've decided to look at some tutorials on how to make simple applications. I've found a pretty good tutorial that tells you how to make a helloWorld app with swt and jFace, and also has an example file explorer that you can make. They both work perfectly from inside eclipse, but when I try and export either one into a .jar file, they don't work anymore. It comes up with a message saying "Could not find main class. Program will exit." In the little wizard it has for exporting, I set the main class to my Explorer class. I think I exported everything I need, but I'm not sure.I tried googling it, but nothing I found worked.If anyone can help me, I'd appreciate it.

Share this post


Link to post
Share on other sites

I am having a similar problem. have you found a solution? I have a main() in the Operation.class used when I run as an Application. I also have an AppletGame.class that has an init() that is used when I run as an Applet. Within Eclipse the both work. But After exporting to a jar, It only works as an Application. Does this look like something you've done before?Thanks a bunch.Hankpublic class Operation { public static void main(String[] args) { Operation operator = new Operation(); operator.global.notApplet(); operator.run(); JFrame frame = new JFrame(); ... } public void run() { String playerName = null; int RC = 0; ... }}public class AppletGame extends JApplet {public GameApplet() { super(); } /** * This method initializes this * @return void */ public void init() { Operation operator = new Operation(); operator.run(); System.out.println("GameApplet"); this.setSize(750, 660); this.setVisible(true); this.setEnabled(true); //JPanel panel = new JPanel(); //panel.add(new Label("Hello World")); this.add(operator.getJPanel()); }...}

Share this post


Link to post
Share on other sites

Well, I figured out how to export the applications right a while ago, with Fat-Jar.

When you're exporting an SWT application, you make sure that all the SWT jar files are in with your project, then you export it, and make sure you set the main class. Then, you have to get the right SWT dll's and make sure they're in the same directory as the application you want to run, and it should work perfectly. I think they have some kind of tutorial on their site for that. If you need more help, just ask.

But I've never really tried putting an applet inside an application. I knew it was possible, but I didn't ever think to do it.

For your problem with JFace, I'm not really sure what it is. I'll look into it, though, and try to get back to you.
If you PM me with some kind of link to your source code or something, I think I could help. And don't worry, I won't steal it. :)
I think it's funner to make stuff myself, anyway.

Share this post


Link to post
Share on other sites

Thanks

Eclipse Exporting .jar Files

 

Not sure what you mean by JFace. Did you mean that for someone else?

 

You mentioned "and make sure you set the main class." Well, that is where I think the problem is. When I prepare to Export the jar. It asks you to select the Entry Class. I see only one option, the class that contains the main() function and not the GameApplet.Class.

 

Keep in mind that it works just fine when I run as an Applet through Eclipse.

 

Thanks

 

-Hank Ag99

Share this post


Link to post
Share on other sites

Well, if you're just trying to make an applet, have you tried making an HTML file, and running it like that? You should just have to Google how to embed applets, and it should work that way.But if you're trying to make an application that runs the applet inside of it, then you should check out the FatJar Eclipse plugin. I have a link to it on my earlier post. It has always worked for me.Just to make sure, you should look in the Jar file with QuickZip, or WinZip or something, and look in the manifest file, and see if it really says that the start class is what it should be. If it is, then it probably has something to do with the class-path. There are a bunch of tutorials online about setting the class-path, and I think they can explain it a lot better than I can, because I never got it to work very good.But using FatJar should make it all really simple. I think they even have tutorials on how to install it for eclipse.

Share this post


Link to post
Share on other sites

Eclipse Exporting .jar Files - Could not find main class. Program will exit.

Eclipse Exporting .jar Files

 

While making the Jar files from Eclipse we are getting the below error messazge .

Eclipse Exporting .Jar Files - Could not find main class. Program will exit.

 

 

-reply by Amarnath

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.