Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

Sorry, you do not have permission to ask a question, You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please type your username.

Please type your E-Mail.

Please choose an appropriate title for the post.

Please choose the appropriate section so your post can be easily searched.

Please choose suitable Keywords Ex: post, video.

Browse

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Logo Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Logo

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Navigation

  • Home
  • About Us
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • About Us
  • Contact Us
Home/ Questions/Q 5718

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Latest Questions

Author
  • 60k
Author
Asked: November 27, 20242024-11-27T11:52:08+00:00 2024-11-27T11:52:08+00:00

Configurando WSL2 com Intellij

  • 60k

Neste breve tutorial faremos uma configuração para instalação da IDE Intellij no WSL2 usando o Ubuntu-20.04, caso nunca tenha feito a instalação desta distro no seu WSL2 minha sugestão é começar Configurando o WSL com o Ubuntu.

Depois de ter realizado a configuração mencionada estaremos prontos para dar inicio, importante também enfatizar que esse tutorial foi inspirado pelo video instalando o Intellij dentro do wsl2 do canal CodaRAM.

Índice

  • Instalando uma interface gráfica no WSL
  • Instalando a IDE pelo JetBrains Toolbox App
  • Instalando o JAVA e o Maven
    • Java
    • Maven
  • Configurando o JAVA e o Maven no Intellij

Instalando uma interface gráfica no WSL

Sim, meu camarada é possível instalar uma interface gráfica para seu WSL2, fazemos isto rodando o comando.

sudo apt install nautilus -y 
Enter fullscreen mode Exit fullscreen mode

Instalando a IDE pelo JetBrains Toolbox App

Basicamente vamos baixar o toolbox APP e fazer a instalação no WSL2, o interessante aqui é que você pode ter todas a ferramentas deles dentro do WSl, mas neste caso estamos focados no JAVA, com já citado a ferramenta vai ficar instalada dentro do WSL então baixe o arquivo da extensão .tar.gz usando sua interface do windows encontre o diretório da distro.

Image description

Dentro do diretório da distro jogue onde quiser o arquivo, lembre que depois de descompactado e instalado ele não terá mais utilidade.

sudo tar -xzf <nome-do-arquivo>.tar.gz -C /opt 
Enter fullscreen mode Exit fullscreen mode

Feito isso agora temos o arquivo descompactado na pasta /opt navegue até esta pasta e encontre o diretório com mesmo nome do arquivo descompactado.

cd /opt  cd <nome-do-arquivo> 
Enter fullscreen mode Exit fullscreen mode

Neste diretório roda o comando para iniciar a instalação de fato do tool box.

./jetbrains-toolbox 
Enter fullscreen mode Exit fullscreen mode

Se tudo estiver saindo como o esperado teremos a seguinte tela.

Image description

No meu caso já tenho instalado o Intellij IDEA Community, mas posso atualiza-lo ou instalar qualquer outras ferramentas. Feito isso, temos que fazer nossa IDE ficar acessível para o windows usando os seguintes comandos.

navegamos até o diretório e executamos um ls

  cd ~/.local/share/applications   ls 
Enter fullscreen mode Exit fullscreen mode

O resultado é algo parecido com as linhas apresentadas abaixo.

jetbrains-idea-ce-566a045c.desktop   jetbrains-toolbox.desktop   
Enter fullscreen mode Exit fullscreen mode

Agora executamos o comando:

sudo cp *.desktop /usr/share/applications 
Enter fullscreen mode Exit fullscreen mode

Se tudo estiver certo temos a seguinte imagem aparecendo no seu menu do windows, permitindo abrir o Intellij Community de dentro do WSL2

Image description

Instalando o JAVA e o Maven

Para instalar o JAVA e o Maven no Linux Ubuntu é simples, inicialmente vamos executar os seguintes comandos.

Java

Para atualizar o sistema

sudo apt update 
Enter fullscreen mode Exit fullscreen mode

Instalando o JRE(Java Runtime Environment)

sudo apt install default-jre 
Enter fullscreen mode Exit fullscreen mode

Verificando se a instalação está correta

java -version 
Enter fullscreen mode Exit fullscreen mode

A resposta deve ser algo como

openjdk version "11.0.20.1" 2023-08-24  OpenJDK Runtime Environment (build 11.0.20.1+1-post-Ubuntu-0ubuntu120.04)  OpenJDK 64-Bit Server VM (build 11.0.20.1+1-post-Ubuntu-0ubuntu120.04, mixed mode, sharing) 
Enter fullscreen mode Exit fullscreen mode

Pronto, de maneira semelhante temos que vamos instalar o JDK(Java Development Kit)

sudo apt install default-jdk 
Enter fullscreen mode Exit fullscreen mode

Verificando se a instalação está correta

javac -version 
Enter fullscreen mode Exit fullscreen mode

E sua resposta deve ser:

javac 11.0.20.1 
Enter fullscreen mode Exit fullscreen mode

Maven

Observe que para o Maven fazemos também 3 passos

sudo apt install maven 
Enter fullscreen mode Exit fullscreen mode

Verificando se a instalação está correta

mvn -version 
Enter fullscreen mode Exit fullscreen mode

E sua resposta deve ser:

Apache Maven 3.6.3 Maven home: /usr/share/maven Java version: 11.0.20.1, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64 Default locale: en, platform encoding: UTF-8 OS name: "linux", version: "5.15.90.1-microsoft-standard-wsl2", arch: "amd64", family: "unix" 
Enter fullscreen mode Exit fullscreen mode

Configurando o JAVA e o Maven no Intellij

Temos IDE, Linguagem de programação e gerenciador de pacotes em pleno funcionamento o que nos falta agora é fazer Nossa IDE reconhecer a localização do Java e do repositório do Maven o .M2

Com sua IDE aberta digite o comando Ctrl + Alt + s para abrir as configurações, procure por Build, Execution, Development > Build Tools > Maven e preencha os campos com os seguintes valores.

Maven home path: /usr/share/maven

User settings… /home/<seuUsuario>/.m2/settings.xml

Local repository… /home/<seuUsuario>/.m2/repository

Para terminar procure por Build, Execution, Development > Build Tools > Maven > Runner e no campo do JRE coloque

JRE: /usr/lib/jvm/java-1.11.0-openjdk-amd64


OBS: Pode ser que quando você precisar instalar novos pacotes do Maven a IDE tenha algum problema e não deixe realizar o update, para esse caso verifique qual usuário é dono da pasta no diretório do usuário usando o comando:

cd ~ ls -la 
Enter fullscreen mode Exit fullscreen mode

Se o diretório .m2 estiver com o usuário root então mude para o seu pelo comando:

sudo chown -R seuUsuario:seuUsuario .m2   
Enter fullscreen mode Exit fullscreen mode

Agora sua IDE consegue atualizar sem problemas.

javatutorialwebdevwsl2
  • 0 0 Answers
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

Sidebar

Ask A Question

Stats

  • Questions 4k
  • Answers 0
  • Best Answers 0
  • Users 1k
  • Popular
  • Answers
  • Author

    How to ensure that all the routes on my Symfony ...

    • 0 Answers
  • Author

    Insights into Forms in Flask

    • 0 Answers
  • Author

    Kick Start Your Next Project With Holo Theme

    • 0 Answers

Top Members

Samantha Carter

Samantha Carter

  • 0 Questions
  • 20 Points
Begginer
Ella Lewis

Ella Lewis

  • 0 Questions
  • 20 Points
Begginer
Isaac Anderson

Isaac Anderson

  • 0 Questions
  • 20 Points
Begginer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help

Footer

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise

Querify Question Shop: Explore, ask, and connect. Join our vibrant Q&A community today!

About Us

  • About Us
  • Contact Us
  • All Users

Legal Stuff

  • Terms of Use
  • Privacy Policy
  • Cookie Policy

Help

  • Knowledge Base
  • Support

Follow

© 2022 Querify Question. All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.