kalahari
kalahari

Reputation: 974

How to change run as java application settings in Eclipse

I am doing a Java project in Eclipse on Windows. I implemented some methods and tried to test them. But, in Eclipse run or run as seem to be empty.

When I try to right click to my project on package explorer and choose run as Java Application, a pop-up shows up and says Select Java Application. But the list under it looks like completely strange to me. And in the same pop-up, at the bottom there is a package name which is not my projects's package. Actually it is exactly the same package where I copied some methods with copy paste. (I changed them in my project). But it seems to be run settings somehow became default or something.

This is a school hw and my teacher gave me some files with method definitions. I created a project in Eclipse and copied the files into src folder.

So, the question is, how can I change this and run my own project? Thanks in advance...

NOTES: My project is a Java project. I am trying to connect from Eclipse to MySQL using JDBC and run some queries. Connector jar file is on place. Path settings seem to be right.

EDIT: My teacher wants me to implement an interface named ICPL. So I created a java file named CPL. My teacher also gave me a separate Main.java file.

main function class path run config main source

Upvotes: 2

Views: 15793

Answers (3)

AsSiDe
AsSiDe

Reputation: 1846

Make Sure:

  1. you are working on the Jave Perspective . There are various prespective in Eclipse.
  2. when you created your project, have u selected file>new>Java Project.
  3. right click on you project in project explorer,then choose run configuratin,in the "type filter text" text box type "java application" ,select it and choose prespective link on the right side.
  4. select Java Application in "Application Type/Launchers:" list box. Then select "Java" in "Run" drop down box.

  5. apply>ok

  6. here you go.

Upvotes: 1

Mladen Uzelac
Mladen Uzelac

Reputation: 1261

Right click on the class that contains the main method and the use Run as Java application.
Or when you click on the project and have that multiple choice check for the class with a main method.

Great eclipse tutorial for beginners:
http://eclipsetutorial.sourceforge.net/workbench.html
http://eclipsetutorial.sourceforge.net/totalbeginner.html
http://eclipsetutorial.sourceforge.net/persistence.html
http://eclipsetutorial.sourceforge.net/debugger.html

Upvotes: 0

nikoliazekter
nikoliazekter

Reputation: 757

Do you have main method? Try Run - Run Configurations - Java Application and create new launch configuration.

Upvotes: 0

Related Questions