Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Not able to run the successfully compiled programs in cmd, even after adding the "."  RSS feed

 
akash kumar
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends earlier i was able to run the programs without any problem from the coomand promt. But for the past 15 days i'm not able to run the programs but the programs are getting compiled sucessfully. What coutld be the problem?

This is the exception raised when i try to run the compiled program
----------Exception in thread "main" java.lang.NoClassDefFoundError: hi


This is the program.

public class hi
{
public static void main(String args[])
{
System.out.println("This is class hi");
}
}
[ August 16, 2007: Message edited by: akashkumar kumar ]
 
fred rosenberger
lowercase baba
Bartender
Posts: 12542
48
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
your classpath most likely does not contain the '.' directory.

you can try doing

java -cp . hi

(i think that is the correct syntax)
 
akash kumar
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Fred Rosenberger! Thanks relpying.

Runnig the program as "java -cp . hi" works, but not being able to run the program in usual manner even after editing the classpath by including the ".". what can i do?
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by akashkumar kumar:
... Runnig the program as "java -cp . hi" works, but not being able to run the program in usual manner even after editing the classpath by including the ".". what can i do?

Did you open a new command prompt after making the change? On some operating systems, you will even need to reboot before it takes effect.

If that still doesn't work, make sure that there are no spaces before or after the dot in your classpath.

(Finally, do you really need a system classpath? If not, remove it and Java will look in the current directory by default.)
 
akash kumar
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks marc weber and Fred Rosenberger! It's working fine now.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!