Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

I have problem with Compiling and Runing Java file with JDK

 
Bashir Mirzad
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Every body
I have a problem with the jdk, when I am going to compiling my java file in Command Prompt I am typing JAVAC name_of_file.java
then I can compile but when I am going to run this file I am typing JAVA name_of_file, I cna not run the file
it give me this message
C:\java test
Exceptin in thread "main" java.lang.No.SuchMethodError: main
thanks
Bashir
 
Brent Worden
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Give this a shot:
java -cp . test

------------------
Brent Worden
http://www.brent.worden.org/
 
Altaf Raja
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bashir Mirzad:
Hi, Every body
I have a problem with the jdk, when I am going to compiling my java file in Command Prompt I am typing JAVAC name_of_file.java
then I can compile but when I am going to run this file I am typing JAVA name_of_file, I cna not run the file
it give me this message
C:\java test
Exceptin in thread "main" java.lang.No.SuchMethodError: main
thanks
Bashir

type this:
c:\ set classpath=.;
then run
c:\java urClassFile
hope this works

------------------
 
Bashir Mirzad
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys
I still have the problem, I am using Win2000 and set the classpath .; and I a have the path for jdk like this
C:\jdk1.3.0_02\bin, I can compile my program but I can not run that
thanks
[This message has been edited by Bashir Mirzad (edited December 05, 2001).]
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remove the semicolon from your classpath statement.

Also make sure that if your class is inside a package, that the *.class file is placed inside an appropriate folder structure (one that reflects the package structure).

I'm also moving this to Java In General - Beginners
 
Evil is afoot. But this tiny ad is just an ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!