• Post Reply Bookmark Topic Watch Topic
  • New Topic

Regarding Excution of Java program  RSS feed

 
upendra varma
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when i complied a java program
like
javac c:\path\....\demo.java
it is compiling
but during execution by giving in this form
java c:\path\....\demo
it is not executing
could you pls some suggestion why it is not executing
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because when you execute a Java program, you specify the name of the class, and not of a file path. Try this:

java -cp c:\path\... demo

The "-cp" switch sets the classpath, which tells Java where to look for classes. Note the space between the path and the name of the class ("demo").
 
Justin Fox
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
just set the path to the bin, so you can just call javac and java from cmd

Justin
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!