aspose file tools*
The moose likes Java in General and the fly likes Java code do not execute Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Java code do not execute " Watch "Java code do not execute " New topic
Author

Java code do not execute

Alpesh Gediya
Greenhorn

Joined: Nov 23, 2009
Posts: 24
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.






Alpesh Gediya
Do not re-invent the wheel.
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
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

Joined: Nov 23, 2009
Posts: 24
I have administrator right for my account.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42281
    
  64
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.


Ping & DNS - my free Android networking tools app
Alpesh Gediya
Greenhorn

Joined: Nov 23, 2009
Posts: 24
Hello, Ulf Dittmer

Its working fine now, but i still not understand why that was happening. even though i set CLASSPATH.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39409
    
  28
Don't set a system classpath.
 
Consider Paul's rocket mass heater.
 
subject: Java code do not execute