Jav could not find the main class...Program will exit
I just dont seem to be getting the class file to execute from a command line for my utility built in Selenium (works fine when run from Eclipse IDE).
When i try the following:
java -cp C:\FAST\DeveloperDesktop\workspaces\default\SLAB\b in\ MyClass
java -classpath . MyClass
it gives me a java.class lang Classnot foundexception
C:\Users\O559038>java -cp C:\FAST\DeveloperDesktop\workspaces\default\SLAB\b in\
Picked up JAVA_TOOL_OPTIONS: -agentlib:jvmhook
Picked up _JAVA_OPTIONS: -Xrunjvmhook -Xbootclasspath/a:C:\bin\JAVA_S~1\classes;
Exception in thread "main" java.lang.NoClassDefFoundError: MyClass
Caused by: java.lang.ClassNotFoundException: MyClass
at java.net.URLClassLoader$1.run(URLClassLoader.java: 200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.j ava:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:3 07)
at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:2 52)
at java.lang.ClassLoader.loadClassInternal(ClassLoade r.java:320)
Could not find the main class: MyClass. Program will exit.
I have not configured the JAVA_HOME environment variable and running command from a random directory location
Is this a JUnit test you're trying to run?
If so, you don't run it directly, you need to feed it through a testrunner.
the utility has just a main method which calls a couple of fucntions and does it job, its not a TestNG / Junit test
Did you run JavaC first to compile it to a class?
In eclipse, it'll handle compiling it to some sort of /bin directory for you.
I did not do this, since running from Eclipse was automatically compiling the project for me (Build Automatically option) was selected so i already had the class file with me. I tried a variety of things but just dont seem to be able to overcome this
I actually want to put all the code into a bat file and execute the utility from a peer machine (manual testing folks) so they can gain the full benefit of it since every1 has java installed on their machines. Please help me out on this