Note that there are some explanatory texts on larger screens.

plurals
  1. POerror when trying to run application from command line: cannot find class
    primarykey
    data
    text
    <p>I did a module in Java in college but we did it all using Eclipse. Now I'd like to go back and learn it but by using the command line.</p> <p>I set up a folder on my desktop, wrote out my application and saved it as 'MyFirstApp.java'. Here it is:</p> <pre><code>public class MyFirstApp { public static void main (String[] args) { System.out.print("Hello World!"); } } </code></pre> <p>I opened my command line, cd'd into the appropriate directory and then compiled by typing "javac MyFirstApp.java". This creates a file in the folder called "MyFirstApp.class".</p> <p>However when I try to run this by typing "java MyFirstApp" I get an error:</p> <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: MyFirstApp Caused by: java.lang.ClassNotFoundException: MyFirstApp 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) Could not find the main class: Share.class. Program will exit. </code></pre> <p>I also tried running by typing "java -cp.MyFirstApp" but then I get this error:</p> <pre><code>Unrecognised option: -cp.MyFirstApp Could not create the Java Virtual Machine </code></pre> <p>Is this likely to be a problem with my environmental variables? I don't really know much about all this stuff.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload