Compiled program won't System.out

333 views Asked by At

I created a runnable .jar, but it doesn't seem to start. I use System.out.println(), but there is 0 output. Do I have to do something else in order to output something, or can you only output something in the console when testing in Eclipse, and not when you have compiled the program?

I run my .jar by double-clicking, guess that's the way to do it...

Nevermind me, I just googled it and it should be done by using the command line! So, in advance, Google before asking... Sorry!

EDIT: I tried running java -jar [FILENAME] (with correct filepath), but it says that 'java' is not recognized as an internal or external command, while I have java installed. I found on Google that you had to edit the PATH, did that and it still didn't work... Can someone help me?

1

There are 1 answers

3
rolfl On

System.out works fine in the regulat terminal, not just Eclipse.

You must have something else wrong. I suggest you add System.out.println("Starting my program"); as the first line in your main() method.

If you do not get this as output, then it is certain that you are not in fact running your program, but perhaps something else.

With the information you have given it is not possible to say what that other things could be, or what you have wrong.

Adding -verbose:class when you run your jar may help you figure some things out, but, it may also just make things more complicated too.