Melo Mashabane

Greenhorn
+ Follow
since May 03, 2016
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Melo Mashabane

Solved it for anyone else stuck.

- Check your javac path on Windows using Windows Explorer C:\Program Files\Java\jdk1.8.0_91\bin and copy the address.

- On Windows Go to Start - right click on Computer - Select Properties - Select Advanced system settings - Select Environment Variables - Under System variables, scroll and look for 'Path' (without the markers) and Insert the address at the beginning of 'Path' followed by semicolon. i.e C:\Program Files\Java\jdk1.8.0_91\bin; . Do not delete the path existent, just click in and go to the far left end and paste the line above. Do not try anything else, because you just need to link your code to "javac.exe" and you just need to locate it.

- Close your command prompt and reopen it,and write the code for compile and execution.
7 years ago
Error messages:

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C:\Users\mashabanem>cd C:\temp

C:\temp>javac packagea/ClassA.java packageb/ClassB.java
'javac' is not recognized as an internal or external command,
operable program or batch file.

C:\temp>java packageb.ClassB
Error: Could not find or load main class packageb.ClassB

C:\temp>java -cp ".;C:\temp\someOtherLocation;c:\temp\myJar.jar" myPackage.MyCla
ss
Error: Could not find or load main class myPackage.MyClass

C:\temp>


==================================================

Compiling Code With Packages

Following the Windows Setup

1. Create the two files:

- C:\temp\packagea\ClassA.java
- C:\temp\packageb\Class.B.java

2. Then type this command:

cd C:\temp

3. To compile, type this command:

javac packagea/ClassA.java packageb/ClassB.java

4. To run, type this command:

java packageb.ClassB
7 years ago
Hi

I issue running the below code, saved a as Zoo.java:



The OCA Java SE 8 Programmer 1 Study Guide instructs to execute the following:

$ javac Zoo.java
$ java Zoo

When I execute:

$ javac Zoo.java

I get the following error message:

'$' is not recognized as an internal or external command, operable program or batch file.

When I remove the $ sign I get the below message.

'javac' is not recognized as an internal or external command, operable program or batch file.

Be really grateful to get advise on the above as I am revising for the OCA programmer 1 exam and would benefit from running code using Notepad and Command Prompt instead of an IDE.

Kind regards.
7 years ago
@ Zachary Griggs Thank you for that. When I use the command prompt I get the following error message:

'$' is not recognized as an internal or external command, operable program or batch file.

When I remove the $ sign I get the below message.

'javac' is not recognized as an internal or external command, operable program or batch file.



@Henry Wong thank you for your participation.

You may feel that this is not the the appropriate location for this question, however the authors of the OCA Java SE 8 Programmer 1 Study Guide advise that this forum be used for this question.

Kind regards
7 years ago
What tools am we to use for the below? An IDE or Notepad and the command tool?

On page 6 (of the above reference) it instructs to compile and execute the below code into a file called Zoo.java



and execute the following.

$ javac Zoo.java
$java Zoo

7 years ago