• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java code do not execute

 
Alpesh Gediya
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, Friends

public class Test

{
public static void main(String ars[])
{
System.out.println("Hello");
}
}

when i compile above code at [b] windows desktop[/b] and .class file also generates if try to run than i am getting "NoSuchMethodError".
but if i compile above code at location other than windows desktop and copy class file to windows desktop then it executes fine.

code that compiled at other than windows desktop location , if i copy that .class file to windows desktop and use try to run then it works as expected.
but .class generated at windows desktop do not execute at any other location.


please help me on this...

Enviorment varible is set.

i manually set classpath at windows desktop location then also it's not working.




 
Somnath Mallick
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well check if the windows desktop folder has execution rights or not! Could be a access rights issue. Just a guess though!
 
Alpesh Gediya
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have administrator right for my account.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What, exactly, are you typing at the command line to run that class? Something like "java Test" should do the trick no matter in which directory you are.

Since you mention the CLASSPATH variable, I'd advise not to use that. It's generally less troublesome to specify any directories or libraries as part of the command (using the "-cp" switch). Note that all paths needs to be put into double quotes if they contain spaces.
 
Alpesh Gediya
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, Ulf Dittmer

Its working fine now, but i still not understand why that was happening. even though i set CLASSPATH.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49865
71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't set a system classpath.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic