Javac does not compile. java

Asked

Viewed 6,198 times

2

The error of return is this, when I am already in the folder appears this information:

--javac Main.java

'--javac' não é reconhecido como um comando interno
ou externo, um programa operável ou um arquivo em lotes.

I tried without traces and even with a dash. I’m using Intellij Idea as IDE.

  • 1

    Do you have the JAVA_HOME variable set in the environment? Are you running the commands in the Java directory (Java"version of jdk" bin)? And you are using the commands by cmd?

  • Yes, the problem was that it did not compile, so I’m trying the eclipse run and it worked. I installed java 8.

4 answers

12


After installing the JDK (Java Development Kit), open the properties of your computer, (inserir a descrição da imagem aqui + Pause Break or InitiateControl PanelSystem) and click on Advanced System Settings.

inserir a descrição da imagem aqui

Click on Environment variables...

inserir a descrição da imagem aqui

Click on New and create the following two variables:

CLASSPATH = .;%JAVA_HOME%
JAVAHOME = Caminho do Java instalado

After creating variables, edit the variable Path and put a semicolon (;) at the end of the value and add the folder path bin where Java was previously installed:

inserir a descrição da imagem aqui

After configuring these steps, restart your computer to apply the settings and you can compile your code .java simply typing javac and the file name .java in the prompt of Windows. And running informing java followed by the previously compiled class.

To leave the response documented...

  • Welcome and good answer, Renato, +1

  • Papaya with sugar. Congratulations, very detailed.

  • Good your tip... I’ll try it. It’s well explained and summarized.

  • 1

    @Renato I edited your answer because some images were "broken".

2

You set up the compiler path? possible solution This IDE you are using may not compile directly, recognizing the compiler path; you have checked this detail?

Tried to compile by direct prompt?

  • Yes. command was not accepted at the prompt, I will try with eclipse.

  • Man, simply a luxury... https://www.youtube.com/watch?v=LnORjqZUMIQ&list=PLGxZ4Rq3BOBq0KXHsp5J3PxyFaBIXVs3r

  • I took a look at your link looks great. Thank you

  • I used the eclipse and rode smoothly with the run...

0

I had the same problem!

After installing JDK, at the prompt I consulted java -version and rotated normally. However the javac -version did not compile and present the message 'javac' is not recognized as an internal or external..., even with all environment variables properly configured.

The solution:: I checked that the java-version was different from the one I had just installed, there were two versions installed on the machine I was preparing. I uninstalled the previous version, re-entered the prompt and compiled it well.

0

Whenever accessing a system for programming in Java, run java -version to see if Java is installed.

If already installed, this problem occurs because of non-set environment variables. The operating system uses PATH to save paths that can be accessed globally within the operating system, without specifying the total path, only the file name in a folder.

Since javac is in just PROGRAM FILES/JAVA 1.6/bin, you need to create this entry in the environment variables, thus allowing global access to the contents of this folder.

  • 1

    I suggest you take a look at http://answall.com/editing-help and also in [Answer]

Browser other questions tagged

You are not signed in. Login or sign up in order to post.