Skip to main content
gamedev.net
🔒 Locked

[java] Moving Java Project to Eclipse

Started by Paul65 3 replies 1.3k views
Original Post
Paul65
Paul65
I have been working on a java project recently that I have been building and running from the command line. I now want to move it to the Eclipse IDE so that I can take advntage of its debugging etc.. This is proving more difficult that you might imagine it to be. Are there any tutorials on this? I tried doing the following:

1.Go to menu, choose file->new->java project, give project name "test" then finish
2.Right click on "src" folder down side and choose "import"
3.All my source files are in a package "com.goodna.musicmaker" inside a folder "com\goodna\musicmaker". On the pop up that appears, I choose "file system" then the folder with all my source in, then select all the .java files and finish.
4.Now I have all my source files listed in the package explorer

Sadly cant seem to run or build it or anything now. Whats the secret? I've done what seemed the obvious thing to do.
Zakwayda
Zakwayda
I haven't used the 'import' feature, so I can't tell you off the top of my head whether that part of things is correct.

Here's a couple of (maybe too obvious) questions though. First, are there any errors? If not, have you tried right clicking on the (or a) source file with a main() function and choosing 'Run As'?
Paul65
Paul65
I chose the source file with the main function in it and chose "run as java application", then an error comes up saying "selection does not contain a main type". It doesnt seem like it even tried to build anything. Also looking in the bin folder, its just copied all the java files there and theres no class files. Its like its treating the file as binary.
Zakwayda
Zakwayda

I chose the source file with the main function in it and chose "run as java application", then an error comes up saying "selection does not contain a main type". It doesnt seem like it even tried to build anything. Also looking in the bin folder, its just copied all the java files there and theres no class files. Its like its treating the file as binary.

Can you post the main() function (or at least the signature)?

Does it look like this:

public static void main(String args[]) {...}
?

[Edit: I suppose if you were already building and running the project successfully from the command line, the problem probably isn't something so obvious as an incorrect signature for main(). In any case, a Google search for the error you're receiving seems to return quite a few hits; here's one of them.]
Paul65
Paul65
Finally I've sorted it! The problem was that my source files ended in .Java rather than .java! Eclipse wasnt recognizing them as java files. I bet I'm not the first to come up against that problem.


[quote name='Paul65' timestamp='1308029707' post='4823062']
I chose the source file with the main function in it and chose "run as java application", then an error comes up saying "selection does not contain a main type". It doesnt seem like it even tried to build anything. Also looking in the bin folder, its just copied all the java files there and theres no class files. Its like its treating the file as binary.

Can you post the main() function (or at least the signature)?

Does it look like this:

public static void main(String args[]) {...}
?

[Edit: I suppose if you were already building and running the project successfully from the command line, the problem probably isn't something so obvious as an incorrect signature for main(). In any case, a Google search for the error you're receiving seems to return quite a few hits; here's one of them.]
[/quote]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.