473,408 Members | 2,025 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

can't run java program in dos prompt

Hi.
I created simple Hello World application that compiles&runs ok in NetBeans 6.1 but when I try to run it with command line

java main

it says that:
Expand|Select|Wrap|Line Numbers
  1. Exception in thread "main" java.lang.NoClassFoundDefFoundError:main(wrong name).
and some other thing

Advice very appreciated.
Dec 2 '08 #1
4 4243
pronerd
392 Expert 256MB
Well for starters you are trying to execute your source code. You need to use the compiled class file, not the Java source file. The command should be java main.class. The class also has to have a main method, and any dependant classes have to be in the class path.
Dec 2 '08 #2
Nepomuk
3,112 Expert 2GB
You want to do this:
Expand|Select|Wrap|Line Numbers
  1. javac main.java
  2. java main
Greetings,
Nepomuk
Dec 2 '08 #3
By mistake I wrote
java main.java

in my previous post.

Actually what I entered was
java main

After which compiler said that it cannot find main class.
Dec 2 '08 #4
Nepomuk
3,112 Expert 2GB
Well, first of all, the compiler is javac - this is the java virtual machine (jvm).

Now, does main.java contain a main method? And also, is it in any package (which would be indicated by package name-of-the-package at the top of main.java)?

Oh, and do any other files belong to the project?

Greetings,
Nepomuk
Dec 2 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Sharp | last post by:
Hi I would like to use Java to run the windows command prompt (a program) and execute a particular statement (eg. cd\program\...). Is this possible? Any help appreciated. Cheers Michael
6
by: ahin | last post by:
can any one help or give an idea about writing or from where to strat the following program? • Load a list of available courses from a text file into an array (max 4 courses). File format can...
0
by: south622 | last post by:
I'm taking a beginning Java course and I'm stuck in week eight of a nine week course. If anyone could help me I would greatly appreciate it. This assignment was due yesterday and each day I go past...
3
by: MBReikowsky | last post by:
Ok this is homework, and I have wrestled with this for quite awhile now. My program is supposed to give an error message if the user enters any invalid entries. The program works great when the user...
5
sammyboy78
by: sammyboy78 | last post by:
I'm trying to create a program that continuously asks for user input until the user inputs "stop" for employee name which will terminate the program. I have compiled the following code but when the...
6
by: =?Utf-8?B?VkIgSm9ubmll?= | last post by:
ASP.NET 2.0 / Visual Studio 2005 / VB.Net 2.0 I have a web interface that needs to launch a java application. What a long strange trip it has been... I am using Process.Start process start...
3
by: hostel | last post by:
Hi, i set the classpath what ever required and my java program is running fine . i have installed jdk in C:\ , am saving my files in D:\ while compling in command prompt i have to go...
4
by: NickiWood | last post by:
I am in a beginners Java programming class. So far I am doing ok in the class, although there are some things that I am sure will come in time. Right now we are doing an onging project that started...
7
by: swethak | last post by:
Hi, i have a command to convert the video file into image ffmpeg -i sample.wmv -f image2 -t 0.001 -ss 3 ss.jpg i run that one in command prompt it converted the video file into...
0
blazedaces
by: blazedaces | last post by:
So in another thread I posted someone suggested I monitor the heap space usage using jstat, which lead me to jconsole which does something similar, but is more of a GUI. The problem I'm having...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.