Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

same class names

 
rengarajan vaikuntam
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe this is a classpath problem!?
 
Yogesh Chhawasaria
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just wondering are you using some kind of IDE or you execute the program manually via command prompt.
 
rengarajan vaikuntam
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yogesh
im using NetBeans IDE.
Thanx,
Renga
 
Yogesh Chhawasaria
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic