jxhyc
jxhyc

Reputation: 211

Eclipse running previous program

It is a new problem. I copy paste a program and try to run it in eclipse. But the eclipse keeps running an older program. I have no idea what is going on. ( I saved the program as someone on the internet suggested) In the run button, there are only old programs. So I goes into the run configuration option and double clicked the java application option and somehow the one I am working on right now appeared. And I am able to compile and run the current one. So technically I solved the problem, but I would like an explanation, what was going on?

enter image description here

Upvotes: 5

Views: 66202

Answers (4)

sam7kand
sam7kand

Reputation: 59

It just copies path of the server from old project. It has the TWO solutions :

1) you can simply click on your Tomcat->Modules (Web Modules)-> Edit

enter image description here

And simply change the path with you project name or just put "/".

enter image description here

OR

2) You can right click on your project -> Properties-> Web Prjoect Settings

edit Context root, just simply put "/"

enter image description here

Thank you

Upvotes: 0

Teresa Fitzgerald
Teresa Fitzgerald

Reputation: 19

I run into the same problem (I am new in java). I solved the problem by * I ensure did not use the defaul package . Step 1. Create java application. Step 2. Create package (stay away from default package). Step3. Create a class that will have my getters and setters (example:

package revature;

public class Test {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Student s = new Student();
        s.setName("vijaiy");;
        //getting value of the member
        System.out.println(s.getName());

    }

}

Step 4. Create the main class to run the program Example:

package revature;

public class Test {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Student s = new Student();
        s.setName("vijaiy");;
        //getting value of the member
        System.out.println(s.getName());

    }

}

My problem was that I did not set up my brain to think 'java', I was thinking on 'javascript'.

Upvotes: -1

Andrew Lyubovsky
Andrew Lyubovsky

Reputation: 107

Exit out of eclipse, then open Eclipse in a new Workspace and create a new Project. This is a quick solution if you are willing to have multiple workspaces.

Upvotes: -3

Jonah Graham
Jonah Graham

Reputation: 7970

What is going on here is how Eclipse decides what to Run when you press the Run button. My suspicion is you have settings which are causing it to launch the last launched item, rather than something new that does not have a launch configuration. If you hover over the Run icon, it will show the name of the launch configuration that Eclipse will launch.

For a new program, you want to do a Run As -> Java Application (From Run menu).

To configure the default launching behaviour, see Preferences -> Run/Debug -> Launching, and then set the options you want in the Launch Operation group.

launching preference page

Upvotes: 13

Related Questions