Results 1 to 20 of 40
- 07-26-2007, 06:25 PM #1
Member
- Join Date
- Jul 2007
- Location
- in Hamburg, Germany
- Posts
- 4
- Rep Power
- 0
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:
Java Code:/* Hello.java */ public class Hello { public static void main(String[] args) { System.out.println("Hello, world"); } }
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?
thanksLast edited by levent; 07-26-2007 at 07:15 PM. Reason: Code placed inside [code] tag.
- 07-26-2007, 07:16 PM #2levent Guest
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!
- 07-26-2007, 09:23 PM #3
Member
- Join Date
- Jul 2007
- Location
- Las Vegas
- Posts
- 14
- Rep Power
- 0
You should use Eclipse
Eclipse.org
- 07-26-2007, 09:44 PM #4
Member
- Join Date
- Jul 2007
- Location
- in Hamburg, Germany
- Posts
- 4
- Rep Power
- 0
thanks, I change the comand javac with javac. it works.
- 07-26-2007, 09:45 PM #5
Member
- Join Date
- Jul 2007
- Location
- in Hamburg, Germany
- Posts
- 4
- Rep Power
- 0
I mean javac with javaw naturly
- 07-27-2007, 09:34 AM #6
Senior Member
- Join Date
- Jul 2007
- Posts
- 130
- Rep Power
- 0
Java Code:You should use Eclipse Eclipse.org
It's not very helpful for begginers to use an IDE without understanding concept
@Aryubi, compile with javac first, then run it using javaLast edited by cruxblack; 07-27-2007 at 09:41 AM.
- 07-27-2007, 07:04 PM #7
Member
- Join Date
- Jul 2007
- Location
- Las Vegas
- Posts
- 14
- Rep Power
- 0
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
- 07-27-2007, 07:40 PM #8
Senior Member
- Join Date
- Jul 2007
- Posts
- 130
- Rep Power
- 0
Maybe u should poll in this thread, check it out
http://www.java-forums.org/other-ide...tepad-ide.html
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:cool:
- 07-27-2007, 10:45 PM #9
Senior Member
- Join Date
- Jul 2007
- Posts
- 135
- Rep Power
- 0
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.
- 04-28-2008, 01:05 PM #10
Member
- Join Date
- Apr 2008
- Posts
- 1
- Rep Power
- 0
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
- 04-28-2008, 01:57 PM #11
Senior Member
- Join Date
- Jul 2007
- Posts
- 135
- Rep Power
- 0
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?
- 04-29-2008, 05:04 AM #12
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,370
- Blog Entries
- 1
- Rep Power
- 26
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.
- 04-29-2008, 06:15 AM #13
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
- 09-29-2008, 11:11 PM #14
make a batch file and place it in the same directory of your program...
Java Code:cd\ M: \\Replace it by the drive ur file is in ie C: cd YourJavaFilePath javac FileName.java java FileName>results.txt
example: this batch runs M:\JavaServerClientProgram\LocalScan.java and gives output in results.txt
Java Code:cd\ M: cd JavaServerClientProgram javac LocalScan.java java LocalScan>results.txt
Last edited by GhosT; 09-29-2008 at 11:13 PM.
- 12-02-2008, 09:49 PM #15
Member
- Join Date
- Dec 2008
- Posts
- 5
- Rep Power
- 0
I had the same error today, when im trying to debug my application with (Run as Java Application) they are giving me the error : ''Could not find the main class. The program will exit.'' This error is applied to every applications I had (and always worked before) and all these application have a Main Class. I didnt change the settings or my Eclipse version. :confused:
Give me some feedback plz.
- 12-02-2008, 09:53 PM #16
It might have something to do with the workspace. Are you 100% positive the workspace is the same as before? I loaded a project on a flash drive into eclipse and it changed my workspace to the flashdrive so no programs stored on my harddrive would run even though it said the workspace was my harddrive.
- 12-02-2008, 09:58 PM #17
Member
- Join Date
- Dec 2008
- Posts
- 5
- Rep Power
- 0
Yes I am sure im in the good workspace. I think the whole error description could help you to find my problem, and I think this is an Eclipse version problem.
There's the error description :
java.lang.UnsupportedClassVersionError: Bad version number in .class file
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.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 java.lang.ClassLoader.loadClassInternal(Unknown Source)
- 12-02-2008, 10:03 PM #18
I have never even heard of an UnsupportedClassVersionError.
Try deleting all the .class files and just recompiling. Go oldschool and break out javac if it still doesn't work.
What version of Eclipse are you using? Have you tested it on a newer or older version?
- 12-02-2008, 10:07 PM #19
Member
- Join Date
- Dec 2008
- Posts
- 5
- Rep Power
- 0
Im using the compiler version 1.6
- 12-02-2008, 10:11 PM #20
Member
- Join Date
- Dec 2008
- Posts
- 5
- Rep Power
- 0
Similar Threads
-
Error: Could Not Find Main Class. Program Will Exit
By silvia in forum New To JavaReplies: 2Last Post: 09-22-2011, 09:48 PM -
how to right a program that find kth number in two sorted array?
By fireball2008 in forum New To JavaReplies: 8Last Post: 04-22-2008, 03:21 AM -
Call a main method from within a running program
By zoe in forum New To JavaReplies: 1Last Post: 08-07-2007, 06:16 AM -
problems to find the main method
By christina in forum EclipseReplies: 2Last Post: 08-06-2007, 07:51 PM -
How to exit the program..
By coco in forum New To JavaReplies: 1Last Post: 08-01-2007, 05:56 PM
Bookmarks