0

Given this:

javac is the java compiler. It compiles the file, but has no output if there are no warnings or errors.

What can I use to view the file from a user's perspective- user is suppose to see a vending machine that allows them to buy certain stuff from vending machine.java, apparently just running javac somevendmachine.java is not really helping.

There are no errors from javac or feedback, so based on that assumption and the feedback from a prior question, I know the code works; however, how do I set the java code such that a user can now choose selections from the vendingmachine.java or what do I install or read?

2 Answers 2

4

After you compiled your code you can start it using java <class name>. Your class must have a method:

public static void main( String[] args )

This method is executed when you start your program.

Sign up to request clarification or add additional context in comments.

1 Comment

"java VendingMachine" also works, I was going to use an IDE but I ditched the IDE's, so I am tinkering with the command prompt, again thanks.
2

javac only compiles the code to a class file.

You then need to run the class file through the Java virtual machine by typing

java VendingMachine

2 Comments

Yeah, that's exactly what I did:java VendingMachine, worked like a charm, thanks, I was so going to ditch Java for C++, but now I will keep both and play with them, sweet.
And thanks for the clarification, I was like, where did the class file come from if I did not put it there? So javac compiles code to a class file; then, you run the class file via java someclassname.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.