• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

How to set up JDK to start executing programs

 
Ranch Hand
Posts: 95
5
Eclipse IDE Oracle AngularJS C++ Chrome Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello everyone

I just got the book to get the certification for OCA Java SE 8 programmer I

Last year, I followed all of the instructions to download JDK and I hope I did it right. In the image that you can see, some parts read JRE but using the help eclipse I selected the JDK. This program is very complex and the tutorial is long. Nevertheless, I have spent a few hours going over the basics but I am not sure how to fully set it up. If anyone has the same book by Jeanne Boyarsky and Scott Selikoff on page 6, I am trying to execute the first program:

$javac Zoo.java

$ java Zoo

it says to make sure that "you have added it to the PATH". I am frustrated because I want to keep studying the book but I want to do the exercises. Please help me out





I have never run any Java programs but I have knowledge on how Java works. I just need help setting it up to start programming.
 
author & internet detective
Posts: 42134
937
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Daniel,
Welcome to CodeRanch!

The book gives instructions for writing a command line program. The PATH is an environment variable. On Windows, you set a user environment variable. If you want to use Eclipse, this shows how to set up a JDK. I recommend practice with the command line as you study as you will learn more. It looks like you do have the JDK set up though and are up to using Eclipse to create a new class file named Zoo.

Also note that the book recommends this is your second Java book. It moves fast if you've never done any Java before.
 
Sheriff
Posts: 11606
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Daniel Andres,

First of all, a warm welcome to CodeRanch!

Daniel Andres wrote:I have never run any Java programs but I have knowledge on how Java works. I just need help setting it up to start programming.


When you have none or little experience with Java (and compiling/running Java programs) the best way is to use the command line, not an IDE. At first, it will be a little harder because the IDE does several things automatically for you (like compiling all classes when you make a change). It also gives you code completion, spots compiler errors,... But on the exam you don't have the Java compiler at your disposal and thus you have to spot the compiler errors yourself, you have to know parts of the Java API and so on. That's why I always advice to use your favourite text editor and javac + java to create, compile and run Java programs.

To create, compile and run your first Java program, follow the steps from the "Hello World!" application lesson (of Oracle's Java Tutorials). Choose for the command-line instructions of either Microsoft or Linux (not NetBeans IDE).

If you still have some doubts and/or questions after reading both threads, just hit the reply button and let us know

Hope it helps!
Kind regards,
Roel
 
Daniel Andres
Ranch Hand
Posts: 95
5
Eclipse IDE Oracle AngularJS C++ Chrome Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Jeanne Boyarsky and Roel!

Roel De Nijs wrote: To create, compile and run your first Java program, follow the steps from the "Hello World!" application lesson (of Oracle's Java Tutorials). Choose for the command-line instructions of either Microsoft or Linux (not NetBeans IDE).



Roel, I installed and set up NetBeans and I was able to compile and run Hello World. If you use the same program, do you know why after I clicked run / Build Project (HelloWorldApp) it didn't open the output Hello_World_App window as you can see here



However, when I ran the main project it worked



Is this an issue as I advance with more programs?

---------------------------------------------------------------------------------------------------------------------------

If you looked back at the image of the page that I posted on my previous post, could you tell me what this means? What is that dollar symbol? I am currently reading that is an inner

$ javac Zoo.java

$ java Zoo

As I said, I have never programmed in Java so I am not familiar with all of the the symbols yet. I am looking for information online but nothing refers back to this example.

 
Roel De Nijs
Sheriff
Posts: 11606
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Once more, I would not use an IDE at all. Not NetBeans, not Eclipse, no IDE at all.

Daniel Andres wrote:Roel, I installed and set up NetBeans and I was able to compile and run Hello World. If you use the same program, do you know why after I clicked run / Build Project (HelloWorldApp) it didn't open the output Hello_World_App window as you can see here


I'm not a NetBeans user so no clue at all

Daniel Andres wrote:If you looked back at the image of the page that I posted on my previous post, could you tell me what this means? What is that dollar symbol? I am currently reading that is an inner

$ javac Zoo.java

$ java Zoo


The dollar sign is indeed used internally by the compiler to decorate names of .class files of inner classes. But inner classes is not on the OCAJP exam (it's on the OCPJP one). So no need to worry about it here! In this context it's nothing more than the shell prompt on a Linux/Unix machine. On a Windows machine a > is often used.

Let's assume you have written the Java source code file Zoo.java
Next you'll open a command prompt and then you can compile and run the program using these commandsThe above commands will only work if both javac and java are on the PATH system variable. More info and a step-by-step guide can be found here.

Hope it helps!
Kind regards,
Roel
 
Jeanne Boyarsky
author & internet detective
Posts: 42134
937
Eclipse IDE VI Editor Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have used NetBeans. It (annoyingly) insists that the project you want to run be designated as the main project. So yes, that's normal.
 
Daniel Andres
Ranch Hand
Posts: 95
5
Eclipse IDE Oracle AngularJS C++ Chrome Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Roel De Nijs wrote:Once more, I would not use an IDE at all. Not NetBeans, not Eclipse, no IDE at all.



Got it!

I was finally able to add it to the PATH so that I could work with command prompt

The above commands will only work if both javac and java are on the PATH system variable. More info and a step-by-step guide can be found here.


Thank you so much! It took me a long time to set it up, more than it should have, but I am happy now that I can continue with the book

 
Daniel Andres
Ranch Hand
Posts: 95
5
Eclipse IDE Oracle AngularJS C++ Chrome Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jeanne Boyarsky wrote:I have used NetBeans. It (annoyingly) insists that the project you want to run be designated as the main project. So yes, that's normal.



Thank you
 
Roel De Nijs
Sheriff
Posts: 11606
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Daniel Andres wrote:Thank you so much! It took me a long time to set it up, more than it should have, but I am happy now that I can continue with the book


Glad to hear you sorted everything out and you are now up and running, ready to produce a gazillion of code snippets!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic