Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Console

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


can anybody please explain what to do when this program is run through Command prompt.I get this output after i compile and run this program in cmd.
java propogate???Please explain?


Exception in thread "main" java.lang.NoClassDefFoundError: Propogate/class
Caused by: java.lang.ClassNotFoundException: Propogate.class
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: Propogate.class. Program will exit.
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

gunjan khanuja wrote:
java propogate???


1. java is case sensitive
2. that class file has package
 
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do you run your java command?

java Propogate.class

or

java Propogate
 
gunjan khanuja
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i ran the code using both the statements and i got this error..Please clarify


D:\Mobility\eclipse\workspace_abhijeet\Propagate\src\com\tcs>java Propogate
Exception in thread "main" java.lang.NoClassDefFoundError: Propogate (wrong name



: com/tcs/Propogate)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: Propogate. Program will exit.

D:\Mobility\eclipse\workspace_abhijeet\Propagate\src\com\tcs>java Propogate.clas
s
Exception in thread "main" java.lang.NoClassDefFoundError: Propogate/class
Caused by: java.lang.ClassNotFoundException: Propogate.class
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: Propogate.class. Program will exit.

D:\Mobility\eclipse\workspace_abhijeet\Propagate\src\com\tcs>


 
John Jai
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should have your package structure in the java cmd.

So it should be java com.tcs.Propogate

Also note that there should be a package structure com/tcs/Propogate.class in the classpath.
 
Ranch Hand
Posts: 583
Firefox Browser Notepad Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do one thing delete previous compiled "Propogate.class" and "Propogate.java.bak" file and then recompile it.Some times i also get same problem.
 
John Jai
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

gunjan khanuja wrote:
Exception in thread "main" java.lang.NoClassDefFoundError: Propogate (wrong name


This error typically comes when you have the class name without the valid package structure.
 
When evil is afoot and you don't have any arms you gotta be hip and do the legwork, but always kick some ... tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic