Confusion with making new projects/java files [message #878917] |
Wed, 30 May 2012 03:44  |
Eclipse User |
|
|
|
Hi I just started using Eclipse, and I'm still a bit unfamiliar with some very basic stuff. One question I have is regarding creating files. The first thing I wanted to do is create a simple hello world program
class HelloWorld{
public static void main(String[] args){
System.out.println("Hello World");
}
}
which works fine when I create a class file within a java project. However, when I create a general file and then name it helloworld.java, it says I have no main method. What is the distinction between the two, and why does it do that?
Another thing I'm having trouble with is importing preexisting java files. I have in a folder, several .java files and .png images for a project I did a while back. When I try to use the import, with a file system, I can see all the files in that folder in the package explorer. But when I try to run the file, it gives me the same main method error as above. This is really puzzling as I used to use JCreator, and I could compile and run that same file with no problems at all. What would be the correct way to import preexisting related java files in a folder?
Thanks for your help.
|
|
|
Re: Confusion with making new projects/java files [message #879110 is a reply to message #878917] |
Wed, 30 May 2012 10:32  |
Eclipse User |
|
|
|
Make sure that the project is a Java project (when you create the project select Java project from the available project types.) Make sure that the java files are on in a source folder. The Properties dialog for a Java Project will have a Build Path section. On the Source tab will be a list of source folders.
You may want to go through the Java tutorial in the Help section. It explains project organization and setup.
|
|
|
Powered by
FUDForum. Page generated in 0.30128 seconds