my dog learned polymorphism*
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 Android Security Essentials Live Lessons this week in the Android 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: 41133
    
  45
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: 38044
    
  22
Don't set a system classpath.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java code do not execute
 
Similar Threads
2 Questions - I'm really at a loss!
Main not found, but it exists!
Problem in start of BeeServlet.java / autoexec.bat file
2 Questions - I'm Really At A Loss!
Java compiler