Missing tools.jar in SpringTools Suite when invoking via command line

孤街醉人 提交于 2020-03-04 23:07:30

问题


I'm seeing the following screen:

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:

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:

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:

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


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  

回答1:


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.



来源:https://stackoverflow.com/questions/60081014/missing-tools-jar-in-springtools-suite-when-invoking-via-command-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!