Exception in thread “main” java.lang.NoClassDefFoundError: Hello

This is my first project with Java. I'm using Ubuntu.

I'm in the folder /home/anis/jtest/myProject and I run the Hello.java file with :

javac src/org/example/Hello.java

Seems that works. I get no error and a Hello.class file in the example directory.

Then from the myProject firectory again I run :

java -cp src/org/example Hello

and I get the error : Exception in thread "main" java.lang.NoClassDefFoundError: Hello (wrong name: org/example/Hello)

My code for Hello.java is :

package org.example; public class Hello { public static void main(String[] args) { System.out.println("Hello\n"); } }


In folder src/:

$ javac org/example/Hello.java $ java org.example.Hello


  • java.lang.UnsupportedClassVersionError: com/google/doclava/Doclava : Unsupported major.minor version
  • Java “Hello World” program running issue
  • Accessing variables in other classes (Java)
  • How to access fields declared inside anonymous object?
  • python & Mysql: unsupported operand type(s) for -: 'int' and 'tuple'
  • Color syntax highlighting in Bash while using R
  • Gem not installing package
  • including Python.h in C++ file CDT
  • Exposing an enum in a QML signal
  • CUDA Debugging - VS on windows workstation, GPUs on Linux server?
  • What is ./.local/share/Trash (Unix) [closed]
  • Building Qt project for C++11 standard
  • Python pickle not one-to-one: different pickles give same object
  • How to view images from protected folder with php?
  • Display images in Django
  • Read a local file using javascript
  • ImageMagick, replace semi-transparent white with opaque white
  • Cannot connect to cassandra from Spark
  • Resize panoramic image to fixed size
  • Cross-Platform Protobuf Serialization
  • Importing jscolor library in angular 2
  • Large data - storage and query
  • Alternatives to the OPTIONAL fallback SPARQL pattern?
  • Why winpcap requires both .lib and .dll to run?
  • WOWZA + RTMP + HTML5 Playback?
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • How to format a variable of double type
  • Load html files in TinyMce
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • Hits per day in Google Big Query
  • Understanding cpu registers
  • coudnt use logback because of log4j
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • Java static initializers and reflection
  • Linking SubReports Without LinkChild/LinkMaster
  • unknown Exception android
  • XCode 8, some methods disappeared ? ex: layoutAttributesClass() -> AnyClass
  • JaxB to read class hierarchy
  • Observable and ngFor in Angular 2
  • Unable to use reactive element in my shiny app