Two Laptop Bag*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes same class names Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "same class names" Watch "same class names" New topic
Author

same class names

rengarajan vaikuntam
Ranch Hand

Joined: Oct 04, 2004
Posts: 37
Hi
I have one folder name C:\SAMPLES under which i have this code

public class MyFirstProg {
public static void main(String as[]) {
System.out.println("FIRST PROG IN SAMPLES FOLDER");
}
}

compiles and executes ok.

I have one more folder C:\PROJECTS in which i have a prog with same class name
public class MyFirstProg {
public static void main(String as[]) {
System.out.println("FIRST PROG IN PROJECTS FOLDER");
}
}
compiles and executes ok.

But when i go back to my samples folder ,open MyFirstProg class and execute it, to my surprise the one in the projects folder only is getting executed.
Could anyone explain why?
Thanx
renga.
rogel garcia
Ranch Hand

Joined: Dec 19, 2003
Posts: 41
Maybe this is a classpath problem!?


SCJP 1.4
Yogesh Chhawasaria
Ranch Hand

Joined: Apr 02, 2004
Posts: 53
Just wondering are you using some kind of IDE or you execute the program manually via command prompt.


When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
rengarajan vaikuntam
Ranch Hand

Joined: Oct 04, 2004
Posts: 37
yogesh
im using NetBeans IDE.
Thanx,
Renga
Yogesh Chhawasaria
Ranch Hand

Joined: Apr 02, 2004
Posts: 53
Well SCJP expects u 2 be a walking compiler... After reading your few other posts I can just reach the conclusion that you aint really much familiar with command prompt execution and classpath issues.
I can only advise you to leave the IDE alone initially and spend time with command prompt and start from basics....
but again these are just my thoughts...
shri mon
Ranch Hand

Joined: Jan 11, 2005
Posts: 63
use a different package name for both the programs and include both the directories in the classpath.Never work with orphan classes..
ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
I think , NetBeans IDE will have a button for execution & when we will click on that it will execute the last successful file ( In WSAD , it is ) . ( In WSAD there is a option - Run as a application : for running current file )
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: same class names
 
Similar Threads
using the javac -cp command
doubt 3
Urgent Help.........
static, instance, constructor call order
Help with Packages