I get no output when I compile Java code from the Terminal











up vote
4
down vote

favorite












When I try to run my Hello World program it doesn't show any output:



$ ls
hello.class hello.java
$ javac hello.java
$









share|improve this question




















  • 1




    I thoughtjavac was just the compiler, then once it's compiled you run your program with java
    – Nick Weinberg
    Jul 10 '16 at 14:32








  • 2




    Possible duplicate of How to run a Java program in Ubuntu
    – karel
    Jul 10 '16 at 14:33






  • 6




    Please don't post screenshots of text. Instead, paste the text directly into your question and use the formatting tools.
    – terdon
    Jul 10 '16 at 14:53






  • 1




    @terodactyl fixed
    – cat
    Jul 11 '16 at 12:07















up vote
4
down vote

favorite












When I try to run my Hello World program it doesn't show any output:



$ ls
hello.class hello.java
$ javac hello.java
$









share|improve this question




















  • 1




    I thoughtjavac was just the compiler, then once it's compiled you run your program with java
    – Nick Weinberg
    Jul 10 '16 at 14:32








  • 2




    Possible duplicate of How to run a Java program in Ubuntu
    – karel
    Jul 10 '16 at 14:33






  • 6




    Please don't post screenshots of text. Instead, paste the text directly into your question and use the formatting tools.
    – terdon
    Jul 10 '16 at 14:53






  • 1




    @terodactyl fixed
    – cat
    Jul 11 '16 at 12:07













up vote
4
down vote

favorite









up vote
4
down vote

favorite











When I try to run my Hello World program it doesn't show any output:



$ ls
hello.class hello.java
$ javac hello.java
$









share|improve this question















When I try to run my Hello World program it doesn't show any output:



$ ls
hello.class hello.java
$ javac hello.java
$






command-line java compiling gedit






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jul 12 '16 at 5:28









Zanna

49.2k13124234




49.2k13124234










asked Jul 10 '16 at 14:26









FRANK KARUGANDA

2113




2113








  • 1




    I thoughtjavac was just the compiler, then once it's compiled you run your program with java
    – Nick Weinberg
    Jul 10 '16 at 14:32








  • 2




    Possible duplicate of How to run a Java program in Ubuntu
    – karel
    Jul 10 '16 at 14:33






  • 6




    Please don't post screenshots of text. Instead, paste the text directly into your question and use the formatting tools.
    – terdon
    Jul 10 '16 at 14:53






  • 1




    @terodactyl fixed
    – cat
    Jul 11 '16 at 12:07














  • 1




    I thoughtjavac was just the compiler, then once it's compiled you run your program with java
    – Nick Weinberg
    Jul 10 '16 at 14:32








  • 2




    Possible duplicate of How to run a Java program in Ubuntu
    – karel
    Jul 10 '16 at 14:33






  • 6




    Please don't post screenshots of text. Instead, paste the text directly into your question and use the formatting tools.
    – terdon
    Jul 10 '16 at 14:53






  • 1




    @terodactyl fixed
    – cat
    Jul 11 '16 at 12:07








1




1




I thoughtjavac was just the compiler, then once it's compiled you run your program with java
– Nick Weinberg
Jul 10 '16 at 14:32






I thoughtjavac was just the compiler, then once it's compiled you run your program with java
– Nick Weinberg
Jul 10 '16 at 14:32






2




2




Possible duplicate of How to run a Java program in Ubuntu
– karel
Jul 10 '16 at 14:33




Possible duplicate of How to run a Java program in Ubuntu
– karel
Jul 10 '16 at 14:33




6




6




Please don't post screenshots of text. Instead, paste the text directly into your question and use the formatting tools.
– terdon
Jul 10 '16 at 14:53




Please don't post screenshots of text. Instead, paste the text directly into your question and use the formatting tools.
– terdon
Jul 10 '16 at 14:53




1




1




@terodactyl fixed
– cat
Jul 11 '16 at 12:07




@terodactyl fixed
– cat
Jul 11 '16 at 12:07










1 Answer
1






active

oldest

votes

















up vote
15
down vote













You can see from ls that you already compiled your program with the compiler javac. The command you used



javac hello.java


creates hello.class without sending any output to stdout, so there won't be any messages in your terminal unless there are errors - what you see is the expected behaviour. If you actually want to see some output, you can add an option: javac -verbose hello.java as mentioned by @Frisky (thanks!)



Now you can run that file hello.class with



java hello





share|improve this answer



















  • 1




    @Zannas answer is correct. But, if you just want to see some output, you can use the -verbose option.
    – Frisky
    Jul 10 '16 at 18:12













Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f797025%2fi-get-no-output-when-i-compile-java-code-from-the-terminal%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
15
down vote













You can see from ls that you already compiled your program with the compiler javac. The command you used



javac hello.java


creates hello.class without sending any output to stdout, so there won't be any messages in your terminal unless there are errors - what you see is the expected behaviour. If you actually want to see some output, you can add an option: javac -verbose hello.java as mentioned by @Frisky (thanks!)



Now you can run that file hello.class with



java hello





share|improve this answer



















  • 1




    @Zannas answer is correct. But, if you just want to see some output, you can use the -verbose option.
    – Frisky
    Jul 10 '16 at 18:12

















up vote
15
down vote













You can see from ls that you already compiled your program with the compiler javac. The command you used



javac hello.java


creates hello.class without sending any output to stdout, so there won't be any messages in your terminal unless there are errors - what you see is the expected behaviour. If you actually want to see some output, you can add an option: javac -verbose hello.java as mentioned by @Frisky (thanks!)



Now you can run that file hello.class with



java hello





share|improve this answer



















  • 1




    @Zannas answer is correct. But, if you just want to see some output, you can use the -verbose option.
    – Frisky
    Jul 10 '16 at 18:12















up vote
15
down vote










up vote
15
down vote









You can see from ls that you already compiled your program with the compiler javac. The command you used



javac hello.java


creates hello.class without sending any output to stdout, so there won't be any messages in your terminal unless there are errors - what you see is the expected behaviour. If you actually want to see some output, you can add an option: javac -verbose hello.java as mentioned by @Frisky (thanks!)



Now you can run that file hello.class with



java hello





share|improve this answer














You can see from ls that you already compiled your program with the compiler javac. The command you used



javac hello.java


creates hello.class without sending any output to stdout, so there won't be any messages in your terminal unless there are errors - what you see is the expected behaviour. If you actually want to see some output, you can add an option: javac -verbose hello.java as mentioned by @Frisky (thanks!)



Now you can run that file hello.class with



java hello






share|improve this answer














share|improve this answer



share|improve this answer








edited Jul 11 '16 at 7:52

























answered Jul 10 '16 at 14:38









Zanna

49.2k13124234




49.2k13124234








  • 1




    @Zannas answer is correct. But, if you just want to see some output, you can use the -verbose option.
    – Frisky
    Jul 10 '16 at 18:12
















  • 1




    @Zannas answer is correct. But, if you just want to see some output, you can use the -verbose option.
    – Frisky
    Jul 10 '16 at 18:12










1




1




@Zannas answer is correct. But, if you just want to see some output, you can use the -verbose option.
– Frisky
Jul 10 '16 at 18:12






@Zannas answer is correct. But, if you just want to see some output, you can use the -verbose option.
– Frisky
Jul 10 '16 at 18:12




















draft saved

draft discarded




















































Thanks for contributing an answer to Ask Ubuntu!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f797025%2fi-get-no-output-when-i-compile-java-code-from-the-terminal%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Quarter-circle Tiles

build a pushdown automaton that recognizes the reverse language of a given pushdown automaton?

Mont Emei