142

I need to set Maven options in machine. I ran following command and I got 'export' is not recognized as an internal or external command

export MAVEN_OPTS=-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n
Damith Ganegoda
  • 4,100
  • 6
  • 37
  • 46

6 Answers6

404

'export' command is valid only for unix shells. In Windows - use 'set' instead of 'export'

aniltilanthe
  • 4,587
  • 1
  • 18
  • 17
  • 2
    Curious case: in gitbash terminal we can run `export` command without problems, but when running a npm start, which happens to trigger start defined in package.json, shows that export command is invalid. An alternative to make export work in gitbash is to create a bash script with export commands in `"scripts": { "start": "mystuff.sh" }`, it works. – Junior Mayhé Mar 15 '21 at 18:43
  • Worth noting is that `set` only sets the variable for that terminal session. It doesn't export it globally so that that env var can be used outside of the terminal. If you need it globally System Properties seems to be the way, if you're lucky enough to have permissions to edit those... – Oskar Lund Feb 07 '22 at 13:40
  • On my end I changed the `export` to `set` in my package.json because it's in one of the script. – user3856437 Jul 02 '23 at 07:35
28

I tried set, didn't work for me, in the end:

 $env:

worked. But you have to put your string in quotes like:

$env:SPOTIFY_CLIENT_ID="XXXX"
artworkjpm
  • 1,255
  • 2
  • 19
  • 40
10

SET does work as mentioned above.

In case anyone wants to know how to use the data stored in variable use %variable%. if you want to print value in command prompt use echo %variable%

ex: SET myVar = testsite.co.uk

To print in command prompt:

echo %myVar%

To use in code, just use %myVar%

jack
  • 1,488
  • 7
  • 25
  • 44
0

Was facing the same issue.Turned out I was doing a rookie mistake. Try this instead:

set MAVEN_OPTS=-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n
CtrlAltElite
  • 487
  • 8
  • 32
0

I am using this way:

$MAVEN_OPTS="-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n"

Dzintars
  • 1,410
  • 21
  • 29
0

Use "git bash here" on Windows it will work. You can install git from https://git-scm.com/downloads

bad_coder
  • 11,289
  • 20
  • 44
  • 72