Cannot Run a Java application on Eclipse

Posted on 2004-11-26
Last Modified: 2010-03-31

If any of you have used eclipse, please let me know what this error means.
I am running an open source code - dtdparser
I tried to run it in eclipse and it compiles fine but at runtime gives the following error in a dialog box:
The active editor doe snot contain a Main type

When I checked the file

It has the main method.

Any thoughts?

Oh and By the way after I build it, its not showing me the class file.
Does it store it in a separate bin directory or something?

Please lemme know
Question by:dkamdar
    LVL 92

    Expert Comment

    LVL 3

    Expert Comment

    > Oh and By the way after I build it, its not showing me the class file.
    > Does it store it in a separate bin directory or something?

    It depends how you configure your project. You can set the "bin" directory, it's the common practice.
    But by default the compiled files (.class) are created in the same directories where source files (.java) are located.
    LVL 1

    Accepted Solution

    Open the properties for your project. Go into the Java Build Path and in there you can specify the folders in your project to compile (that's what is in the "Source folders on build path") and the output for all the class files ("Default output folder"). If you've put your code into folders in your project that aren't part of the package name, make sure they are listed as a source folder. If you need to have any JAR files in your classpath when compiling, switch to the Libraries tab and add them there.

    For example, I'm working on something I've checked out from a CVS repository. It has more than just the source code in there, so the source code is in the /implementation/source folder. Then beneath that are the folders that correspond to the package names. For Eclipse to compile this project I had to change the source folder it was compiling. It was trying to compile from the root directory, which didn't work since the package names didn't start with implementation.source. Once I did that it compiled just fine and I changed the output path to /implementation/build to tell it where to put the class files.

    As long as that all checks out, just make sure that main method is static. I've goofed on that before myself when I was in a rush to write something.

    Featured Post

    Live: Real-Time Solutions, Start Here

    Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

    Join & Write a Comment

    An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
    Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
    Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    25 Experts available now in Live!

    Get 1:1 Help Now