Jul 26, 2008

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

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > Java, Java Servlets, Java Script, & JSP

free web hosting

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

hippiman
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.

Reply

Hank Ag99
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.
Hank


public 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());
}
...
}

 

 

 


Reply

hippiman
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. angel.gif
I think it's funner to make stuff myself, anyway.

Reply

iGuest
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

Reply

hippiman
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.

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Recent Queries:-
  1. how to find main class in java application eclipse - 0.94 hr back. (1)
  2. java tutorial jar file eclipse applet - 10.40 hr back. (1)
  3. eclipse, could not find the main class. - 12.04 hr back. (1)
  4. select main class eclipse jar - 15.29 hr back. (1)
  5. tomcat could not find the main class - 15.81 hr back. (1)
  6. could not find the main class run from eclipse - 16.16 hr back. (1)
  7. could not find main class. program will exit - 17.32 hr back. (1)
  8. manifest "class-path" eclipse - 19.27 hr back. (1)
  9. eclipse exporting jar - 20.38 hr back. (1)
  10. java locate class in jar eclipse - 21.12 hr back. (1)
  11. could not find the main class. program will exit - 21.69 hr back. (1)
  12. eclipse generate jar with no main - 22.97 hr back. (1)
  13. could not find the main class. programm will exit - 23.45 hr back. (1)
  14. java programm starten main class not found - 24.61 hr back. (1)
Similar Topics

Keywords : eclipse, exporting, jar, files, main, class, program, exit,

  1. Jar Executable Files
    (1)
  2. Ajax: Achieve Ajax Program In 5 Lines Of Code!
    (1)
    Well Last night, after a week of irritation and errors I finally created an easy Javascript object
    that easily and quickly allows you to develop an AJAX program in just 5 easy steps! Here's
    the link to the object I've created: http://www.demolaynyc.astahost.com/ajaxConn/ajaxConn.js
    Download it and read the Readme file that's under the same directory:
    http://www.demolaynyc.astahost.com/ajaxConn/Readme.html Basically what this object does is to
    connect to a server-side script (".php, .asp, .jsp, etc"), and what ever this script displays is
    sent back ....
  3. What To Do With .java Files?
    (8)
    Ok, I "know" Java, but what now? What do you do with the .java files? (I'm interested in both
    java-applets and java-programs.) Thanks, Peroim.....
  4. Writing & Reading Files With Jsp
    How to do it? (1)
    I've a project on creating a Movie online booking website that is powered with JSP. Now I'm
    trying to write and read from the file I wrote, but didn't know how. Can anyone with such
    expertise please teach me.. It has to be done with JSP. Thanks in advance......
  5. Running .java Or .class Files From Runtime
    (1)
    from an API and outputs the result to the API (like someAPI.submitResult(myResult), which checks the
    results against the sample values. The idea is that the student is able to click a browse button and
    locate their .java or .class file, which the GUI then launches. So my question is if I can launch
    this class as part of the GUI process so that the API actually is actually part of the GUI process.
    It's a bit backwards really - like launching the API first and then adding in the component that
    uses the API during runtime. But there is an advantage of doing it this w....
  6. Is There A Way To Use Command Prompt Commands?
    To make a program execute cmd stuff (4)
    I looked in the System class because that would make the most sense, but I didn't see anything.
    In C++ it's system(stuff) in stdlib.h. Just looking for something like that.....
  7. Java Basic Program Guidance
    (6)
    aving some problems taking in the Java at Uni, Was wondering if anyone could shine some light on it
    for me. My task is to write a program that will ask you to enter 2 words. the program will then
    print out both words on one line. However the words will be seperated by dots that will make the
    total length of the line 40. so if your first word was turtle and the second was abc, the output
    would be turtle...............................abc The program should check for certain conditions:
    1. a word can not be longer than 37 characters; 2. there must always be atlest 2 do....
  8. Having Trouble Getting Program To Print Out Multip
    (4)
    i'm trying to have a user input a number between 1 to 5, and that number will be the number of
    times the program will print out random 10 digit integers. Example, if user inputs 3, then the
    program will print out 3 random 10 digit intergers. Here's what i have so far Code: CODE
    import java.util.Scanner; import java.util.Random; public class test3 { public static void main
    (String[] args) {  Scanner scan = new Scanner(System.in);  Random
    generator = new Random();  int n=0, times;  String number = "";    Syste....
  9. Deployment Problem: Disappearing Files?
    (1)
    Hi, I am attempting to deploy a web app. I compile it and make it a war. I restart tomcat and the
    war is distributed. I then go onto the internet and type in:
    http://localhost:8080/manager/deploy?path=/myapp a few different things have happened when I have
    typed in the same thing. The most prevelant error is: FAIL - Failed to deploy application at
    context path /myapp...is this error because of my build file or because of my web.xml file?? or
    neither? One time the stupid thing actually deployed. I went back and checked my directory and all
    my files were gone! The ....
  10. Practice More Important To Study A Program Lanuage
    The way to learn a program language (1)
    I had studied the c++ for long time before I got a program work. The books about c++ is seen by me
    again and again. But at that time I wasn't able to do any big program by c++. Though I knew all
    the syntax of c++. It was very terrible. I felt it was very diffcult as a programmer. Now I am a
    excellent programmer, I have written lots of jave code. Some of them is very difficult, for example:
    Workflow Engine. Now I know why I am not able to write a big c++ program but I know all the syntax
    of c++. Use a sentence to express: "Practice more important to study a program ....
  11. Auto Run Java Program
    Run Java program on double click (11)
    Some of the installables in java comes in form of .jar file, one has to just double click or type
    "java -jar file.jar", and it starts executing. The reason for this is a line appended in the
    MANIFEST.MF file of that jar file. For writing a similar jar file of your own, just write your java
    file, then compile the same and create a jar file. Create a MANIFEST.MF file and the content should
    have the followings: CODE Manifest-Version: 1.0 Created-By: xyz Main-Class:
    xyz.MainClass Here xyz.MainClass is the main class. Now create a jar file with the man....

    1. Looking for eclipse, exporting, jar, files, main, class, program, exit,

Searching Video's for eclipse, exporting, jar, files, main, class, program, exit,
advertisement



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



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE