wood burning stoves*
The moose likes Beginning Java and the fly likes Regarding main is not found in command prompt but executed in IDE Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Regarding main is not found in command prompt but executed in IDE" Watch "Regarding main is not found in command prompt but executed in IDE" New topic
Author

Regarding main is not found in command prompt but executed in IDE

subash subbu
Greenhorn

Joined: May 25, 2011
Posts: 17
Hello
Public class Test{ void disp(){Sop("hello")}}
class TestApp{ public static void main(String[] args){Test obj=new Test(); obj.disp(); Sop("hi");}}
FILE NAME: Test.java
It is not executed in command prompt.But executed in Myeclipse IDE. Tel me reason.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11422
    
  16

Since this has nothing to do with jobs, i'll move it to a better forum...

Please try and choose more carefully which forum you post in next time.

Can you please elaborate on what the problem is, and post your actual code? What does "It is not executed in command prompt" mean - do you get an error message of some kind?


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
subash subbu
Greenhorn

Joined: May 25, 2011
Posts: 17
It compiles successfully with Test.java file name.But when we run we get an error main() is not found. But it successfully executed in IDE Myeclipse how?
Akhilesh Trivedi
Ranch Hand

Joined: Jun 22, 2005
Posts: 1527
Radha Krishnna wrote:...successfully executed in IDE Myeclipse how?


IDEs(like MyEclipse) do something for you. Like setting classpath

May be you would like to visit this thread as well.


Keep Smiling Always — My life is smoother when running silent. -paul
[FAQs] [Certification Guides] [The Linux Documentation Project]
subash subbu
Greenhorn

Joined: May 25, 2011
Posts: 17
Thanks for your reply buy i want some more clarity
subash subbu
Greenhorn

Joined: May 25, 2011
Posts: 17
I think maybe it is not related to classpath. in this code main method is not there in public class of the file name
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11422
    
  16

The code you presented will not compile. "Public" isn't valid. you are missing a semi-colon. "Sop" is not a valid method call.

Yes, i know what you mean in all cases, but if you can't be bothered to give us the ACTUAL code you are running, do you really expect anyone here to offer you much help? Your job, when asking a question, is to make it as EASY as possible for someone to help you. You are much more likely to get your question answered.
Rameshwar Soni
Ranch Hand

Joined: Feb 03, 2011
Posts: 247
Radha Krishnna wrote:It compiles successfully with Test.java file name.But when we run we get an error main() is not found. But it successfully executed in IDE Myeclipse how?

When we run...... I think you running your Test class which does not have the main() method. So compile and execute your TestApp file.
Akhilesh Trivedi
Ranch Hand

Joined: Jun 22, 2005
Posts: 1527
Rameshwar Soni wrote:
Radha Krishnna wrote:It compiles successfully with Test.java file name.But when we run we get an error main() is not found. But it successfully executed in IDE Myeclipse how?

When we run...... I think you running your Test class which does not have the main() method. So compile and execute your TestApp file.


There are few things with it,
1. file name and public class (should they be same or different, if same why and if different how?)
2. do i want to run a class or do I want to run a method or do I want to run one and only main method, is it possible that I can run both a class and method?

John Jai
Bartender

Joined: May 31, 2011
Posts: 1776
the IDE is capable of locating and running the main types - in this case the TestApp class. When you compile your Test.java you should get two classes created - Test.class and TestApp.class... so try running the cmd - java TestApp
subash subbu
Greenhorn

Joined: May 25, 2011
Posts: 17
Hi john i already tested java TestApp on command prompt but it gives class not found...
John Jai
Bartender

Joined: May 31, 2011
Posts: 1776
if you have posted real code with the commands and the errors you got as Fred suggested, you should have got the answer by this time.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Regarding main is not found in command prompt but executed in IDE