Re: Brand new user question
Do a dir command in the folder where you use the java command to see what files are there. There needs to be a FirstApp.class file.
Re: Brand new user question
There is a similar question here:
Java problem: Could not find main class HelloWorld - Stack Overflow
The answer seems to be that you need to set your classpath
You should also read this because you may have put the main class in a package so you should run it from the package:
http://www.jarticles.com/package/package_eng.html
Re: Brand new user question
Thanks there wasn't a file FirstApp.class so I did a search in the folder and subfolders and was able to find it. I found it much deeper: C:\<path to folder>\FirstApp\build\classes\FirstApp\FirstApp.c lass
So I type in java FirstApp and got the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: FirstApp
me: firstapp/FirstApp)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknow n Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(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)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unkno wn Source)
Looks like there might be something I didn't install?
Thanks in advance!
Re: Brand new user question
Does the source file have a package statement? That will change how you execute it. You have to include the package name with the classname and set the classpath to the package folder.
For simpler testing, remove the package statement, recompile and try to execute again.
To copy the contents of the command prompt window:
Click on Icon in upper left corner
Select Edit
Select 'Select All' - The selection will show
Click in upper left again
Select Edit and click 'Copy'
Paste here.
Re: Brand new user question
Your Netbeans output path look like classes\FirstApp\FirstApp.class. It look like that your class is inseide a FirstApp package. So to run your code you should start from the classes directory and type something like:
Code:
java FirstApp.FirstApp
Re: Brand new user question
Quote:
Originally Posted by
wsaryada
Your Netbeans output path look like classes\FirstApp\FirstApp.class. It look like that your class is inseide a FirstApp package. So to run your code you should start from the classes directory and type something like:
Code:
java FirstApp.FirstApp
This worked, thank you. I was trying to just run the class file but NetBeans did give a path and command to use to run the program. That is odd because its now how the book I'm reading said to run programs. Thanks, I'll pay more attention to what the program tells me instead of the book since its not about NetBeans.
Thanks for the help all, I'm sure the classpath solution would of worked as well but I didn't quite understand it.
Baby steps, really tiny baby steps.