Question:

How do I run a Java Program after I complile it?

by Guest65155  |  earlier

0 LIKES UnLike

I was able to compile the program, but for some reason, I can't seem to run the program, the name of my program is titled Mirabella, here's a what I did

To compact it I typed in: javac Mirabella.java

Then to run run the program I typed in: java Mirabella.class

What all do I need to do to fix my mistakes

 Tags:

   Report

3 ANSWERS


  1. What exactly happens after you type "java Mirabella.class"? Are you getting an error message?

    If nothing is ever returned, in other words your command prompt just blinks at you, it could be that you have an infinite loop and you're not outputting anything, or your program stops and waits for input that's never provided. Or it could be that you're program is running and exiting and you don't realize it because you have not output anything.


  2. You need to specify the classpath. If all classes are in the current directory then type: java -cp . Mirabella

    The "-cp ." is important so that the JVM knows where to look for the classes. Also you should not specify the ".class" extension. Good luck.

  3. in your Mirabella.java code, have you defined a package?

    If yes, you will need to provide the package name to run the code.

    for example, if package name is com.trial.program then after compiling, you can run it as

    java com.trial.program.Mirabella

    If this is not the case, please give the error you get when you run java Mirabella.class

Question Stats

Latest activity: earlier.
This question has 3 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.