• Post Reply Bookmark Topic Watch Topic
  • New Topic

main class XYZ not found  RSS feed

 
Adrian Baetu
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a class:



Filename: C:\MyJavaTest\MethTest.java

Can't execute it like this:
C:\MyJavaTest>java MethTest
Fehler: Hauptklasse MethTest konnte nicht gefunden oder geladen werden

means that java can't find or load the main class MethTest.

Used JDK:
C:\MyJavaTest>java -version
java version "1.7.0_02"
Java(TM) SE Runtime Environment (build 1.7.0_02-b13)
Java HotSpot(TM) 64-Bit Server VM (build 22.0-b10, mixed mode)

C:\MyJavaTest>set CLASSPATH
CLASSPATH=.;C:\Program Files (x86)\Java\jre6\lib\ext\QTJava.zip;F:\OpenNI\Bin\org.OpenNI.jar

In Eclipse it works.

In a console it won't.

Anny hint's on what I'm missing?
 
Ralph Cook
Ranch Hand
Posts: 479
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need a file named MethTest.class in the default directory -- the one you would see by entering the command "cd" on the command line. This file needs to have been produced by compiling the MethTest.java file.

rc
 
Pavan Kumar Dittakavi
Ranch Hand
Posts: 108
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Adrian,

Did the compilation using 'javac' result in class file?. Did you check that?. Also make sure that you are having that class file in the directory from which you are issuing the 'java' command.

Thanks,
Pavan.
 
John Jai
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Adrian Baetu wrote:In Eclipse it works.

Eclipse auto builds the class files. On running from the cmd prompt you have to compile first using javac command.
 
Adrian Baetu
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yup that's it.
Since I have to explore eclipse as well I started my tests there first and then just not to miss what realy happens in the background I startet the examples in a console.
This one I tried to start first in the console as usual directly with java => no *.class file => ERROR
At the beginning I assumed the .class file gets created by java, on the fly, if missing ( similar to python )
javac I assumed to be necessary only for kind of release-builds(you don't want to execute your project just to generate the *.class. files for delivery )
... but that doesn't seem to be the complete truth ;o).
Manny thanks, now I got it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!