Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-26-2007, 08:25 PM
Member
 
Join Date: Jul 2007
Location: in Hamburg, Germany
Posts: 4
aryubi is on a distinguished road
Could not find the main class, program will exit.
hello everybody,

I have a problem:
1. I install jdk 6 update 2 and jre 6 update 2
2. I enter "C:\Program Files\Java\jdk1.6.0_02\bin" in path of systemvarible
3. I wrot Hello.java as follow:

Code:
/* Hello.java */ public class Hello { public static void main(String[] args) { System.out.println("Hello, world"); } }
4. I change in the Hello.java directory in Dos Window under Windows XP
5. I type java -version and every things ok but as i type javaw Hello.java
I got this message from Java Virtual Machine Launcher:
Cold not find the main class, program will exit.
can somebody help me?
thanks

Last edited by levent : 07-26-2007 at 09:15 PM. Reason: Code placed inside [code] tag.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-26-2007, 09:16 PM
Senior Member
 
Join Date: Dec 2006
Posts: 748
levent is on a distinguished road
4.1. Run "javac Hello.java" to obtain Hello.class file. (Compiling step)
5. Instead of typing "javaw Hello.java", try "java Hello"

Note: And please place your code inside [code] tag next time!
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 07-26-2007, 11:23 PM
Member
 
Join Date: Jul 2007
Location: Las Vegas
Posts: 14
Sircedric88 is on a distinguished road
Send a message via AIM to Sircedric88
You should use Eclipse
Eclipse.org
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 07-26-2007, 11:44 PM
Member
 
Join Date: Jul 2007
Location: in Hamburg, Germany
Posts: 4
aryubi is on a distinguished road
thanks, I change the comand javac with javac. it works.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 07-26-2007, 11:45 PM
Member
 
Join Date: Jul 2007
Location: in Hamburg, Germany
Posts: 4
aryubi is on a distinguished road
I mean javac with javaw naturly
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 07-27-2007, 11:34 AM
Senior Member
 
Join Date: Jul 2007
Posts: 130
cruxblack will become famous soon enough
Code:
You should use Eclipse Eclipse.org
Thats not a solution u know, is this supposed to be some kinda ads?
It's not very helpful for begginers to use an IDE without understanding concept

@Aryubi, compile with javac first, then run it using java

Last edited by cruxblack : 07-27-2007 at 11:41 AM.
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 07-27-2007, 09:04 PM
Member
 
Join Date: Jul 2007
Location: Las Vegas
Posts: 14
Sircedric88 is on a distinguished road
Send a message via AIM to Sircedric88
Haha, well are you just running your programs from the command prompt?
Cuz, I find that to not debug well, it doesn't help you out and is not very organized.

Go to Eclipse.org, and if you want, I could walk you through the steps of installing the program and the IDE
Bookmark Post in Technorati
Reply With Quote
  #8 (permalink)  
Old 07-27-2007, 09:40 PM
Senior Member
 
Join Date: Jul 2007
Posts: 130
cruxblack will become famous soon enough
Maybe u should poll in this thread, check it out

Notepad or IDE?

Running from command prompt does help me from being to spoiled with all the helpful tools though, helps me code more organized, and the trial and error debug makes me realize not only the errors i made, but also the errors i might made
Btw, i had a netbeans, but still, cmd works well for now thank u
Bookmark Post in Technorati
Reply With Quote
  #9 (permalink)  
Old 07-28-2007, 12:45 AM
Senior Member
 
Join Date: Jul 2007
Posts: 134
brianhks will become famous soon enough
I'm not certain this was answered well. Here are the steps:
>javac Hello.java
>java -cp . Hello

The -cp . tells the JVM that the current directory is in the classpath.
Bookmark Post in Technorati
Reply With Quote
  #10 (permalink)  
Old 04-28-2008, 03:05 PM
Member
 
Join Date: Apr 2008
Posts: 1
rajesh2732 is on a distinguished road
hi
hi
while try to access borland star team
i got the error message like colud find the main call. program will exit
can any body help me in this
Bookmark Post in Technorati
Reply With Quote
  #11 (permalink)  
Old 04-28-2008, 03:57 PM
Senior Member
 
Join Date: Jul 2007
Posts: 134
brianhks will become famous soon enough
More detail please
Please give us some more detail as to what you are doing? Like: sample of your main class. any commands you are using to build/run your application?
Bookmark Post in Technorati
Reply With Quote
  #12 (permalink)  
Old 04-29-2008, 07:04 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,566
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Hi rajesh2732,

Welcome to our community.

When you ask a question next time please provide enough details. So others can give a help to you easily. I think at the same time better to read our FAQ page before posting next.

Best of luck with our community.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #13 (permalink)  
Old 04-29-2008, 08:15 AM
Zosden's Avatar
Senior Member
 
Join Date: Apr 2008
Posts: 386
Zosden is on a distinguished road
For beginners, I recommend writing everything in notepad. This helps for you to learn the basics, and once again I'm going to recommend my java tutorial its not complete, but it will last you about a week if you read it all. My webpage
please give back some helpful feedback if you can.
__________________
My IP address is 127.0.0.1
Bookmark Post in Technorati
Reply With Quote
  #14 (permalink)  
Old 09-30-2008, 01:11 AM
GhosT's Avatar
Member
 
Join Date: Sep 2008
Location: Dhaka, Bangladesh
Posts: 37
GhosT is on a distinguished road
make a batch file and place it in the same directory of your program...

Code:
cd\ M: \\Replace it by the drive ur file is in ie C: cd YourJavaFilePath javac FileName.java java FileName>results.txt
so all u need to do is open the text file and check the results...once u make a batch file u can copy paste it to make others...

example: this batch runs M:\JavaServerClientProgram\LocalScan.java and gives output in results.txt
Code:
cd\ M: cd JavaServerClientProgram javac LocalScan.java java LocalScan>results.txt

Last edited by GhosT : 09-30-2008 at 01:13 AM.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to right a program that find kth number in two sorted array? fireball2008 New To Java 8 04-22-2008 05:21 AM
Call a main method from within a running program zoe New To Java 1 08-07-2007 08:16 AM
problems to find the main method christina Eclipse 2 08-06-2007 09:51 PM
How to exit the program.. coco New To Java 1 08-01-2007 07:56 PM
Error: Could Not Find Main Class. Program Will Exit silvia New To Java 1 07-19-2007 06:58 PM


All times are GMT +3. The time now is 11:22 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org