5

Well, i complile my program using this command in Ubuntu

javac -classpath .:/home/ss/lucene-4.0.0/core/lucene-core-4.0.0.jar:/home/ss/lucene-4.0.0/queryparser/lucene-queryparser-4.0.0.jar:/home/ss/lucene-4.0.0/analysis/common/lucene-analyzers-common-4.0.0.jar:/home/ss/lo.jar:/home/neetish/mysql-connector-java-5.1.25-bin.jar kel.java

It compiles.

And I run using

  java -classpath .:/home/ss/lucene-4.0.0/core/lucene-core-4.0.0.jar:/home/ss/lucene-4.0.0/queryparser/lucene-queryparser-4.0.0.jar:/home/ss/lucene-4.0.0/analysis/common/lucene-analyzers-common-4.0.0.jar:/home/ss/lo.jar:/home/ss/mysql-connector-java-5.1.25-bin.jar kel.java

and i Get

Could not find or load main class kel.java

can anyone help me plz

Uwe Plonus
  • 9,803
  • 4
  • 41
  • 48
Neetz
  • 364
  • 5
  • 18

4 Answers4

4

Even though your source file's name kel.java, your class' name is just kel

You have to start your program with

java -cp ... kel

You should not add any suffix to the class name.

zEro
  • 1,255
  • 14
  • 24
Uwe Plonus
  • 9,803
  • 4
  • 41
  • 48
  • 1
    Note that this only applies when *running* the program. When *compiling*, in contrast, it is necessary to include the .java extension. – T-Bull Jun 25 '13 at 09:00
  • @OP: Also make sure that the ``classpath`` is pointed to the directory where the compiled files are put. You might [find this useful](http://stackoverflow.com/questions/3005433/java-problem-could-not-find-main-class-helloworld?rq=1) – zEro Jun 25 '13 at 09:01
  • @T-Bull Comiling is done with `javac` and the original poster had no problem with compiling but with running, which is done by the command `java` as I wroe. – Uwe Plonus Jun 25 '13 at 09:01
  • 1
    @UwePlonus: I know. Just pointed that out to already explain the next source of confusion. – T-Bull Jun 25 '13 at 09:06
0

After compilation, you can run by java kel. Simply remove the .class from you compiled file.

Pyae Thu Aung
  • 303
  • 1
  • 3
  • 10
0

After compilation, just give class name, instead kel.java. Just mention kel.

0

If there is a main() method in kel.java and if it is successfully compile then

you can run it using following command.

java -classpath kel

in your case you are trying to run kel.java. That is wrong.

Ruchira Gayan Ranaweera
  • 34,993
  • 17
  • 75
  • 115