-4

I've just installed eclipse on my mac, i've written a program for it and i am trying to build it.

When i attempt to do so all that appears in the console is the location of my JDK.

I've configured it and set the location to the JDK home folder but still nothing happens.

Can anyone help me with this issue?

Thanks

  • what do you get when you run 'java -version' in a prompt? – Stultuske Jan 23 '18 at 08:12
  • -bash: java-version: command not found – Alexander James Stephens Jan 23 '18 at 08:14
  • 1
    not 'java-version', 'java -version' (a space between java and -version). either you get the currently installed version, or you haven't got JAVA installed (correctly). What command do you use to try and build your code? – Stultuske Jan 23 '18 at 08:16
  • LOL! you need to put a space between `java` and `-version`: `java -version` – Allan Jan 23 '18 at 08:16
  • java version "9" Java(TM) SE Runtime Environment (build 9+181) Java HotSpot(TM) 64-Bit Server VM (build 9+181, mixed mode) I get this when i put the space. – Alexander James Stephens Jan 23 '18 at 08:17
  • ok. so the jre is installed correctly. what command did you use to build your project? – Stultuske Jan 23 '18 at 08:31
  • 1
    follow the steps here if you use eclipse https://stackoverflow.com/questions/13635563/setting-jdk-in-eclipse, you might need to configure your `JAVA_HOME` – Allan Jan 23 '18 at 08:33
  • @AlexanderJamesStephens check your comile/build command, and verify it against your applications setup/configuration. – Stultuske Jan 23 '18 at 08:39
  • Why do you try to build a program on the console when you are using Eclipse that builds the program automatically? Besides that—what did you do in the console and what did you actually expect? Most jdk tools will not print anything when there were no errors. So well, everything fine perhaps? – Holger Jan 23 '18 at 09:10

1 Answers1

1

Do the following steps

Open Terminal

Confirm you have JDK by typing “which java”. It should show something like /usr/bin/java.

Check you have the needed version of Java, by typing “java -version”.

JAVA_HOME is essentially the full path of the directory that contains a sub-directory named bin which in turn contains the java.

For Mac OSX – it is /Library/Java/Home

Set JAVA_HOME using this command in Terminal:

export JAVA_HOME=/Library/Java/Home
echo $JAVA_HOME     

on Terminal to confirm the path You should now be able to run your application

spandey
  • 1,034
  • 1
  • 15
  • 30
  • your explanation is correct if the question would be about running the application. He gets an error trying to build his application, meaning it's the JDK setup or the build command there are problems with. – Stultuske Jan 23 '18 at 08:36
  • Hi, I've followed your steps and the same thing still happens... maybe i have done it incorrectly? – Alexander James Stephens Jan 23 '18 at 08:38
  • same steps I have followed and I am able to run.. its strange you are not able to do.. – spandey Jan 23 '18 at 08:53
  • @spandey15 his problem is not running, it's building. – Stultuske Jan 23 '18 at 08:56
  • LOL, the OP wrote “*When i attempt to do so all that appears in the console is the location of my JDK.*” and you provide something that will do exactly nothing but print the location of the JDK. And to no surprise, the OP’s response is “*I've followed your steps and the same thing still happens*”. The conclusion is, when you don’t know what the OP actually did (*if* he did anything), or what he expected, there is no way to help him. Note that he didn’t even mention whether he did any attempt to run `javac` (or any other jdk tool). – Holger Jan 23 '18 at 09:17