Re: Question:



lei wrote:

Sub: Question:

1st point. A title of 'Question:' is not very helpful.
This post should ideally be split into two parts, the
first titled (something like) 'Run from command prompt'.

Note that title does not mention 'question' or 'problem'
or 'help', which is almost assumed, and the body of the
message can make clear, in any case.

I will deal with only the first, on this thread.

1)If I have two classes, how can i run it in the command prompt? (ex:
java FileName) for only one class.
....
To illustrate:

1)class File{
}

class Main{
}

(good illustration)
The code above shows two classes File and Main,
both with no attributes, and no *methods*, let alone
a method called main (that is of the right form to
be understood as *the* main(String[] args) method
that the JVM looks for, to start a class).

c:\>javac File.java
c:\>java File

The JVM understands that any class to be loaded
and run has a 'main', so ..

Error: Exception in thread "main" java.lang.NoSuchMethodError:main

...here it reports it was unable to find that 'main' method.

Google for HelloWorld in Java and it should show
a valid form for the main.

As an aside, an excellent group for those beginning
Java, is comp.lang.java.help

HTH

Andrew T.

.



Relevant Pages

  • Re: Why FC4 using the Jpackage 1.4.2 Java?
    ... No open source JVM currently exists. ... You can register with Sun and go to Sun's Java sight and freely ... run the Java code optimally on the specific platform. ...
    (Fedora)
  • Re: Help me!! Why java is so popular
    ... My point is that those who use Windows already accept bloatware and the ... I think those are the kinds of things which has made Java popular. ... And don't forget about the very fact that with JVM, ... GUI elements are called components and containers, ...
    (comp.lang.java.programmer)
  • Re: Help me!! Why java is so popular
    ... You are basically arguing that "Java is slow because it is slow". ... > Also, a JVM can pay attention to usage, provide caching, adapt at run ... I have no use for unicode in my ...
    (comp.lang.java.programmer)
  • Re: Dusting off an old JVM discussion
    ... I was wondering how difficult it would be to write a JVM in Forth, ... Upon looking at those "opcode" instructions, ... and I think today's PDA's might have more memory ... I imagine those applications written in Java, ...
    (comp.lang.forth)
  • Re: Clojure vs Java speed
    ... vectors in C/C++ and Java. ... The JIT can't, but the coder can. ... You cannot write code that is both that short and that efficient in Clojure. ... You are on the JVM to interoperate with Java. ...
    (comp.programming)