I have a JavaServer Pages (JSP) application and I’m trying to run it in VSCode using the Community Server Connector extension with Tomcat server. I have some environment variables that are used in the project. They are currently defined in the .bashrc file, but this causes the variables to be defined throughout the machine’s environment. I would like to define them only for the specific project. Is there a way to do this? If so, how?
I have very little experience in the Java universe, but I need to run this project.
When they are configured in .bashrc it works.
2
Answers
The solution that worked best for me was to add "mapProperty.launch.env" to the server settings
To do this, just right-click on the server and then click on Edit Server, a JSON file will open and then I added "mapProperty.launch.env" which receives an object with a set of key-value pairs
https://github.com/redhat-developer/vscode-server-connector/issues/613
you can try creating a
.env
file or script file to set the environment variables. Add<%= %>
to the jsp page to access environment variables directly. Or you can creating a container and develop in a container. This requires theDev Containers
extension to be installed in vscode. Then downloadDocker
to create and manage containers. Click the status bar item in vscode and selectNew Dev Container
to create a new container.