C:\Projects\workspace\com\mypackage>javac HelloWorld.java
and it compiled
Now I am trying to run it
C:\Projects\workspace\com\mypackage>java HelloWorld
Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld (wrong name: com/mypackage/HelloWorld)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
Kannan.DV
If I delete the line
package com.mypackage;
I am able to compile and run this.
Campbell Ritchie wrote:Beware of using IDEs as a beginner; you can spend longer learning about the IDE than about Java.
Alex George wrote:Doesn't seem to be working.
C:\Projects\workspace>java com.myPackage.HelloWorld
Exception in thread "main" java.lang.NoClassDefFoundError: com/myPackage/HelloWorld
-Nathan
"A single conversation with a wise man is better than ten years of study."
Alex George wrote:my HelloWorld.java file is in
C:\Projects\workspace\Project1\src\com\fis\util
my compiled file is in
C:\Projects\workspace\Project1\classes\com\fis\util
my classpath is
C:\Projects\workspace\Project1\classes\com\fis\util
Our first order of business must be this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|