Missing tools.jar in SpringTools Suite when invoking via command line [duplicate]
Asked Answered
S

1

0

I'm seeing the following screen:

similar question

upon STS startup via script:

start /B C:\"Program Files"\SpringTools4\sts-4.5.0.RELEASE\SpringToolSuite4.exe -data %~dp0 -clean -showlocation -vmC:\Java\jdk1.8.0_144\bin\java.exe -vmargs -Xmx1024m -XX:MaxPermSize=256m -vmargs -javaagent:lombok.jar

Here's my SpringToolSuite4.ini:

-startup
plugins/org.eclipse.equinox.launcher_1.5.600.v20191014-2022.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.1100.v20190907-0426
-product
org.springframework.boot.ide.branding.sts4
--launcher.defaultAction
openFile
-vmargs
-Dosgi.requiredJavaVersion=1.8
-Xms256m
-Xmx1024m
-XX:+UseG1GC
-XX:+UseStringDeduplication
--add-modules=ALL-SYSTEM
-javaagent:C:\Program Files\SpringTools4\sts-4.5.0.RELEASE\lombok.jar

JAVA_HOME environment variable is defined:

enter image description here

According to Eclipse documentation:

-vm (Executable, Main)

when passed to the Eclipse executable, this option is used to locate the Java VM to use to run Eclipse. It should be the full file system path to an appropriate: Java jre/bin directory, Java Executable, Java shared library (jvm.dll or libjvm.so), or a Java VM Execution Environment description file. If not specified, the Eclipse executable uses a search algorithm to locate a suitable VM. In any event, the executable then passes the path to the actual VM used to Java Main using the -vm argument. Java Main then stores this value in eclipse.vm.

I checked this for possible pointers and tried different variations of configurations, i.e.:

  • start STS from its .exe file and not from the above script and then specifying the workspace
  • putting -vm option into the .ini file before the -vmargs
  • pointing the -vm to the folder containing the java.exe instead of to that specific file
  • pointing to the javaw.exe instead of java.exe
  • having the -vm point to a JRE directory and not to a JDK one.
  • etc.

Same error persists.

Looks like something redirects STS to look inside C:\Program Files\Java\jre1.8.0_191 instead of C:\Java\jdk1.8.0_144\bin or C:\Java\jdk1.8.0_144\jre\bin where I'm pointing it to.

What could be wrong here?

Thank you in advance.

UPDATE:

As Martin suggested, the following modification:

enter image description here

if invoked by double-clicking the STS executable, results in opening 2 STS windows: a regular STS one (now without the initial missing tools.jar prompt) plus this one:

enter image description here

however, when run via script from the command line, as before, fails to open STS altogether:

enter image description here


THE FINAL SOLUTION:

As correctly pointed out by Martin in his comment, there are several issues with the above script:

  • -vm requires a space after it and the path to the JDK
  • duplicated -vmargs was the culprit causing the initial erroneous behavior
  • pointing to the javaw.exe instead of java.exe helps to hid the second window.
  • -XX:MaxPermSize=256m is no longer necessary under Java 8.

With the above in mind, here is what's working now:

1) The SpringToolSuite4.ini can stay intact, there's no need (although it's possible and working) to add the path to JDK there as pointed in my previous update:

  -startup
    plugins/org.eclipse.equinox.launcher_1.5.600.v20191014-2022.jar
    --launcher.library
    plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.1100.v20190907-0426
    -product
    org.springframework.boot.ide.branding.sts4
    --launcher.defaultAction
    openFile
    -vmargs
    -Dosgi.requiredJavaVersion=1.8
    -Xms256m
    -Xmx1024m
    -XX:+UseG1GC
    -XX:+UseStringDeduplication
    --add-modules=ALL-SYSTEM
    -javaagent:C:\Program Files\SpringTools4\sts-4.5.0.RELEASE\lombok.jar

2) The STS can now be successfully invoked via the following (on Windows):

start /B C:\"Program Files"\SpringTools4\sts-4.5.0.RELEASE\SpringToolSuite4.exe -data %~dp0 -clean -showlocation -vm C:\Java\jdk1.8.0_144\bin\java.exe -vmargs -Xmx1024m  
Sprocket answered 5/2, 2020 at 17:21 Comment(5)
Does this answer your question? Gradle does not find tools.jar You should be using JDK and not JRE.Percentage
@Percentage could you define should be?Sprocket
As per the first answer following the link above - the problem is that JRE has no tools.jar and you must use JDK instead. And from the Spring Tool Suite installation guide: "All the variants require at least a JDK8+ to be installed on your system as a prerequisite".Percentage
Can you uninstall the JRE?Alcinia
@Alcinia Which one? How? Why?Sprocket
P
2

Adding the -vm arg to the .ini file should work, but you need to carefully put that into the right place inside of that file. -vm has to be the first line in that file, followed by an additional like pointing to the java executable of the JDK. Then the third line should proceed with the -startup part that you have in your .ini file.

Postulate answered 6/2, 2020 at 9:20 Comment(4)
Thanks, Martin. I'm seeing some improvements after incorporating your suggestion (see update in the question). How would I modify the startup script with the -vm part to effect the same behavior, as I'd rather have the flexibility of that method then modifying the .ini file? Or, if not, what bring about the second STS windows, I'd rather disable that?Sprocket
With regards to the two windows, I think you can switch from java.exe to javaw.exe to avoid that.Postulate
with regards to the script: I never tried this myself on Windows, but I can see that there is no space between -vm and the actual path to the java executable and -vmwargs is in there twice. Maybe changing both makes a difference?Postulate
Yes, all valid pointers. The -vmwargs was indeed repeated and that's what was messing up the script invocation as well as the space between -vm and the path seems to be required. javaw.exe helps removing the other window. The second window also revealed this helpful warning: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0 so I removed the -XX:MaxPermSize=256m portion in my script. I'm posting the fin solution in an update for the question so it could help someone else. Thanks!!Sprocket

© 2022 - 2024 — McMap. All rights reserved.