Results 1 to 8 of 8
Thread: Error during running
- 07-25-2009, 05:11 PM #1
Member
- Join Date
- Jul 2009
- Posts
- 17
- Rep Power
- 0
Error during running
Hi,
I am an engineering student IT department.
I have error during running an simple java program.
I have set the path correctly and its compiling correctly but when i give
java filename it shows an error saying exception in main thread.
The code i used is
For me appletviewer is working correctly problem only with when i run java program.Java Code:class ak { public static void main(String arg[]) { System.out.println("hai"); } }
Please help me solve my problemLast edited by ak88; 07-26-2009 at 04:53 AM.
- 07-25-2009, 07:08 PM #2
Member
- Join Date
- Jul 2009
- Posts
- 20
- Rep Power
- 0
What do you mean by "problem only with when i run java program"?
Dit you exported it into a jar file?
Can you post the error please?
And if you post a code please use CODE-tags.
[CODE]Your code goes here.[/CODE]
- 07-26-2009, 04:55 AM #3
Member
- Join Date
- Jul 2009
- Posts
- 17
- Rep Power
- 0
when i compile that piece of code no error but when i run the program i get an error
saying Exception in no main foundI didnt use any jar and all
- 07-26-2009, 06:05 AM #4
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,561
- Rep Power
- 11
Copy, paste and post the command you are using and the exact and entire error message you receive.
To compile and run that code from the directory containing ak.java you would typically use something like:
Note that "ak" is not a very good name for a Java class. These start with a capital letter (hance, Ak). Part of the reason for this is that consistent case naming conventions help reduce errors like specifying the class name incorrectly on the command line.Java Code:> javac -cp . ak.java > java -cp . ak
- 07-27-2009, 08:44 AM #5
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
How did you compile and run your code, as pbrockway2 says please provide more details here. So it's easy to help you.
- 07-27-2009, 03:27 PM #6
Member
- Join Date
- Jul 2009
- Posts
- 17
- Rep Power
- 0
compiled using javac ak.java
while running
C:\>java ak
Exception in thread "main" java.lang.NoSuchMethodError: main
- 07-27-2009, 07:51 PM #7
Senior Member
- Join Date
- Sep 2008
- Posts
- 564
- Rep Power
- 5
definitely not a coding problem, but you most likely have something wrong with your classpaths or whatnot. are you aware of packages? trying putting your class into a package and running it that way. it should work with the default (no defined) package, but it's generally frowned upon to do so.
- 07-28-2009, 04:39 AM #8
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Yes, so the next thing to know is all about the classpath setup. But if the classpath is not setup correctly, that javac command complain about that "javac is not recognized command......"
Similar Threads
-
Error running java program using URL
By gio123bg in forum New To JavaReplies: 6Last Post: 06-30-2009, 06:26 PM -
error running java program
By bdasilva in forum New To JavaReplies: 1Last Post: 06-29-2009, 01:46 AM -
[SOLVED] Error while running eclipse
By kimskams80 in forum EclipseReplies: 3Last Post: 07-02-2008, 11:31 AM -
error while running jar file
By ernieBob in forum NetBeansReplies: 1Last Post: 03-25-2008, 11:13 AM -
Help with error message when running JAR via HTML file
By Simmy in forum AWT / SwingReplies: 7Last Post: 08-12-2007, 03:47 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks