• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to run java from command prompt

 
Biodun Adeniji
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have two issues.
1. I need someone to guide me through compiling and running java from command prompt.
2. I am currently in chapter 3 of " Java How to program by Dietel. I don't understand how to run the following codes from eclipse




The second code is




I guess the author used the command prompt to run the program at the same time. Please, how do I go about it go get "Welcome to the Grade Book" as output.
 
Paweł Baczyński
Bartender
Posts: 1971
39
Firefox Browser IntelliJ IDE Java Linux Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello.
Take a look at this tutorial: https://docs.oracle.com/javase/tutorial/getStarted/cupojava/index.html
 
Campbell Ritchie
Marshal
Posts: 53140
124
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Our FAQ is better . Or maybe it isn't better.
You will have to write some sort of code to print, “Welcome to the Gradebook.” Surely you know how to write a print instruction by now?
Please indent your code correctly. You will cause yourself no end of confusion with badly‑indented code. You are probably better off using the command line than Eclipse at this stage.
 
Knute Snortum
Sheriff
Posts: 3326
84
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't understand how to run the following codes from eclipse

* If you haven't already, create a Java Project in Eclipse.  Call it anything ("Play" is fine).
* Paste both classes into the new project.  Tip: You can copy the code and paste it directly into a project by clicking once on the project and typing Ctrl-V, or right-clicking the project and selecting Paste.
* Select the GradeBookTest class
* Press the "Run" icon or the menu item Run -> Run or press Ctrl-F11.
 
Frankie Law
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are new to Java programming and are following Deitel.  You are awesome, because I am learning from the same book as well.

I suggest that you follow the methods used by the book in terms of compilation is concern.
I use IDEA for my IDE so I cannot comment on how Eclipse works.

If you want to know how to do it in command prompt.  This is how you do it.  Provided that you have completed the classpath set up correctly.

1/ Put the .java file on your desktop (Or put it anywhere you store all your projects)
2/ Go into your command prompt and cd you way to your desktop (Or your project folder)
3/ Do javac filename.java
4/ Then java filename to run the application

The program you have will appear to do nothing, but that's because there is no command being issue that tells you that it is doing something.

Hope something helps here.
 
Carey Brown
Saloon Keeper
Posts: 2329
31
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Add print like this
Now when you run it at least you'll see this message.
 
Biodun Adeniji
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks @ all. The issues are resolved.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!