Win a copy of Getting started with Java programming language this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Help needed with 'Error: Could not find or load main class'  RSS feed

 
Sreeram Venkatasubramanian
Greenhorn
Posts: 5
IntelliJ IDE Linux Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I compiled HBase and when I try running the master, I get
    "Error: Could not find or load main class"

The complete class name is org.apache.hadoop.hbase.master.HMaster. I command gave for execution is HMaster class signature is as below.HMaster class has main method with below signatureThe path from where I gave the command has org folder which in turn has following subdirectores apache/hadoop/hbase/master. HMaster.class is present under master directory. I have verified that the case is matching and there is no typo. HRegionServer.class is present under org/apache/hadoop/hbase/regionserver directory.

Any help will be much appreciated.

Thanks,
Sreeram
 
Dana Ucaed
Ranch Hand
Posts: 197
5
Netbeans IDE Oracle Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can try the command java -version.
 
Campbell Ritchie
Sheriff
Posts: 53612
127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dana Ucaed wrote:You can try the command java -version.
I am not convinced that will work.

Sreeram Venkatasubramanian, welcome to the Ranch
 
Norman Radder
Ranch Hand
Posts: 146
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you enter a dir command and the java command and then copy the full contents of the console and paste it here so we can see what happened?
 
Norman Radder
Ranch Hand
Posts: 146
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you try the command without the "s?
java -cp . org.apache.hadoop.hbase.master.HMaster
 
Sreeram Venkatasubramanian
Greenhorn
Posts: 5
IntelliJ IDE Linux Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Campbell for warm welcome

Output of 'java -version'

java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) Server VM (build 25.121-b13, mixed mode)

Output of dir/ls command

hbase-site.xml  hbase-webapps  log4j.properties  META-INF  org

Without "

I get the same error when I run the command 'java -cp . org.apache.hadoop.hbase.master.HMaster'

Thanks,
Sreeram
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 36171
439
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where is HMaster located on your file system? In a directory called master in a directory called hbase etc? Or in a jar? Or somewhere else?
 
Sreeram Venkatasubramanian
Greenhorn
Posts: 5
IntelliJ IDE Linux Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jeanne,

HMaster is located in '/home/sreeram/hbase-master/hbase-server/target/classes/org/apache/hadoop/hbase/master/HMaster.class'.

I execute the java command from '/home/sreeram/hbase-master/hbase-server/target/classes'

Thanks,
Sreeram
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 36171
439
Eclipse IDE Java VI Editor
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thta class has dependencies. It's odd that you are specifying the classpath as the current directory (Which is redundant.)

My guess is that if you run this, it won't work either because hadoop itself isn't in the classpath.
java org.apache.hadoop.hbase.master.HMaster
 
Sreeram Venkatasubramanian
Greenhorn
Posts: 5
IntelliJ IDE Linux Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jeanne,

Yes the class has dependencies. I was however expecting Java to load the main class and throw ClassNotFoundException  whenever it could not find a dependency in the classpath. So that I could keep adding the dependencies as I hit the exceptions.

Thanks,
Sreeram
 
Campbell Ritchie
Sheriff
Posts: 53612
127
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sreeram Venkatasubramanian wrote:. . . I could keep adding the dependencies as I hit the exceptions.  . . .
That sounds like hard work, but ... if there are any missing dependencies, surely you would have found out from the compiler errors?
 
Sreeram Venkatasubramanian
Greenhorn
Posts: 5
IntelliJ IDE Linux Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jeanne, Campbell,

As you suggested I tried running the main class with all the dependencies in the classpath.

The error has gone away ! Thank you !

I find it difficult to understand why Java was complaining that the main class was not found ?

Any thoughts ?

Thanks,
Sreeram
 
Norman Radder
Ranch Hand
Posts: 146
4
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does that mean that the definitions for the extended class and the interface must be on the classpath to prevent the 'Error: Could not find or load main class' message?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!