Could not find main class

Well, I complicate 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 someone help me plz

+4
source share
4 answers

If kel.java has a main () method, and if it compiles successfully, then

you can run it using the following command.

 java -classpath kel 

in your case, you are trying to run kel.java. It is not right.

0
source

Even if your original file name is kel.java, your class name is just kel

You need to run your program with

 java -cp ... kel 

Do not add a suffix to the class name.

+4
source

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

0
source

After compilation, just specify the class name, instead of kel.java. Just specify kel.

0
source

Source: https://habr.com/ru/post/1488030/


All Articles