• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Using Command Prompt In relation to Java  RSS feed

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys i just have a Question in relation to java, What Output do you expect when you use command prompt to compile java programs? Like HelloWorld.java when compiling  are you expecting "Hello World" on the cmd sscreenshot
 
Marshal
Posts: 6008
414
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. Compilation process produces *.class file/-s which can be executed using 'java' command along with an executable Java class name - google for its exact use.
 
Mohamed Said
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Liutauras Vilda wrote:No. Compilation process produces *.class file/-s which can be executed using 'java' command along with an executable Java class name - google for its exact use.



No output in that sense
What is this "Compilation process produces *.class file/-s which can be executed using 'java' command along with an executable Java class name - google for its exact use."
 
Liutauras Vilda
Marshal
Posts: 6008
414
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Mohamed Said wrote:What Output do you expect when you use command prompt to compile java programs?


No output expected.

Liutauras Vilda wrote:Compilation process produces *.class file/-s which can be executed using 'java' command along with an executable Java class name


In order to see some possible output you need to execute your  class after you got it compiled.
 
Java Cowboy
Sheriff
Posts: 16084
88
Android IntelliJ IDE Java Scala Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are several steps involved in writing a program in Java.

First, you use a text editor (or a more sophisticated tool called an IDE - Integrated Development Environment) to create Java source files, such as HelloWorld.java.

Then, before you can run the program it needs to be translated to executable code. That is what the compiler does. You use the compiler to translate the source file HelloWorld.java into a class file, HelloWorld.class, that contains the code that can be run. In the command prompt, you compile the source code with a command like: javac HelloWorld.java. The result will be a file named HelloWorld.class. Note that the compiler does not run the program, so you will not see output from the program such as a "Hello World" message at this step.

Finally, you can run the program by using a command like: java HelloWorld. When you do that, you will ofcourse see the output of the program.

This is explained in more detail in Oracle's Java tutorials: About the Java Technology and Hello World.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!