I wrote a simple Hello World program in notepad and saved it as it should.

What to do next to make this program?

  • Um ... Press the button to compile in the IDE? .. The essence of your difficulties is not clear, try to describe your problem in more detail - YuriySPb
  • Well, if in a notebook, then it is better to start via the command line. But it is better to read Shilda Java 8 there are painted the first step - Vlad Kesya
  • I tried through the command line but without any result at all - D.Kost
  • I propose to answer how to compile and run the code from the command line. - Qwertiy
  • @Qwertiy, voted for rediscovery. if they open it, I'm ready to write the necessary commands for gnu / linux . - aleksandr barakin

1 answer 1

in the gnu / linux operating system, if there are javac and java programs installed, this file is:

 class helloworld { public static void main(String[] args) { System.out.println("hello world!"); } } 

saved in the current directory as helloworld.java , you can compile it with the command:

 $ javac helloworld.java 

and run the received helloworld.class file helloworld.class command:

 $ java helloworld 

conclusion:

 hello world! 

You can install javac and java programs in different ways, the simplest and most logical one is from the repository of your distribution. For example, in debian -base distributions, this can be done with the command:

 $ sudo apt install default-jdk 
  • teams: javac helloworld.java and java helloworld fundamentally different on windows and linux? :) - Grundy
  • @Grundy, I only have a suspicion that the actions in ms / windows are probably similar. I have nowhere to check this suspicion, because I did not mention it in the answer. - aleksandr barakin