Could not Found the main Class in Java while i'm running?

You don't run a Java class by telling it about source code. You tell it which class to run. For example.

You don't run a Java class by telling it about source code. You tell it which class to run. For example: java -cp .

;dnsns. Jar;...... as before ... com.foo. JavaSamp That's assuming a class called JavaSamp in a package of com.foo.

Note that when you compile, you should probably use something like -d . To tell it to put the class files into a folder structure rooted in the current directory, based on the package name within the source file.

Ses with in it one is My Mainclass, while I comple it have the following Names of classes... {DataBaseHelper. Classes,FileEncryption. Class,JavaDemo.

Class,JavaSamp. Class,SendE?mail. Class,WriteHelper.

Class, JavaSamp$1. Class,JavaSamp$2. Class,JavaSamp$3.

Class,JavaSamp$4. Class,JavaSamp$Mye? Mail$1.

ClassJavaSamp$Myemail$2.class...etc } why it should be happened – BenDennison Jun 21 at 9:42 @Ben Ten: (Sorry to interrupt between you and jon) Because you have some anonymous classes in your java file. (In JavaSamp. Java) – Harry Joy Jun 21 at 9:43 @BEN Ten: The JavaSamp$1 etc classes are likely to be anonymous inner classes.

You can ignore them. You just need to find out which class you want to launch - the one containing the main method. – Jon Skeet Jun 21 at 9:44 it shows again error – BenDennison Jun 21 at 10:01 Exception in thread "main" java.lang.

NoClassDefFoundError: jxl/format/CellFormat Caused by: java.lang. ClassNotFoundException: jxl.format. CellFormat at java.net.

URLClassLoader$1. Run(URLClassLoader. Java:202) at java.security.

AccessController. DoPrivileged(Native Method) at java.net.URLClassLoader. FindClass(URLClassLoader.

Java:190) at java.lang.ClassLoader. LoadClass(ClassLoader. Java:307) at sun.misc.

Launcher$AppClassLoader. LoadClass(Launcher. Java:301) at java.lang.ClassLoader.

LoadClass(ClassLoader. Java:248) – BenDennison Jun 21 at 10:01.

To run a java file, you specify which class file (ends with a . Class extension but you don't specify the extension) and the rest of the classes and libraries (with a . Jar extension) are provided in the classpath.E.g.

Java WriteHelper -classpath ";mail. Jar/localedata. Jar; To compile the file, use javac instead.

What you did is you told java to look for java in WriteHelper directory (or package).

You need to include the classes generated in the first step to the class path in the second step.

When you run java WriteHelper. Java you are telling Java to look for a class called "java" in the "WriteHelper" package. It isn't there, and that is what the exception is telling you when it says: Exception in thread "main" java.lang.

NoClassDefFoundError: WriteHelper/java Run the class as java WriteHelper. The java command expects a class name ... not a class file name. There are other problems with the way that you are compiling and running code.

The -cp option and its value must appear before the names of the Java source files (for javac) and the name of the Java class (for java). The java command expects ONE class name, not lots of class names. You need to figure out which class is the one with the public static void main(String args) method and use that one (only) as the java class argument.(I would guess, that if you have a class called Main that that has the main entry point method.) This will only work if the classes are all declared in the default class.

If the source code starts with a package declaration, you need to organize the classes in a directory tree whose components mirror the class packages; see @Jon Skeet's answer. Finally, you would be well advised to read the manual pages for java and javac carefully, along with the linked page that talks about how the classpath works. Once you understand them, this stuff won't seem like black magic anymore.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions