schemacrawler / SchemaCrawler

Free database schema discovery and comprehension tool
http://www.schemacrawler.com/
Other
1.6k stars 199 forks source link

Classpath enhancement on schemacrawler.cmd > Windows install could work much better #168

Closed adriens closed 6 years ago

adriens commented 6 years ago

Environment

Specify the

  • version of SchemaCrawler : ALL
  • version of Java that you are using : ALL
  • operating system and version that you are using : All Windows (cmd batch file issue)
  • relational datavase and version that you are using : All, but not related to databases
  • JDBC driver and version that you are using : All but not related to jdbc drivers

Issue

In fact, i wanted to install it the same way i do with ant, maven, fop, .... At the end, i'll be able to run the command line from any dir.

  1. Unzip the schemacrawler distribution in a local directory
  2. Create an env variable (let's say SC_HOME) that targets schemacrawler dir _schemacrawler
  3. Add SC_HOME to your PATH
  4. Open a new DOS session and run schemacrawler
  5. See that there is a classpath issue as the actual cmd is trying to load jars from the current directory
Erreur : impossible de trouver ou de charger la classe principale schemacrawler.Main
Causé par : java.lang.ClassNotFoundException: schemacrawler.Main

...classic classpath issue.

adriens commented 6 years ago

If, instead of the current code :

@java -classpath lib/*;config;. schemacrawler.Main %*

you put this one :

@java -classpath %~dp0/lib/*;%~dp0/config;. schemacrawler.Main %*

the classpath will get the correct path, the one that targets the deployed dir.

adriens commented 6 years ago

To make short, as soon as schemacrawler.cmd will be in the PATH, it will run on any directory.

adriens commented 6 years ago

In fact, it's the same trick as the shell's one 😄


#!/bin/sh
java -cp $(echo lib/*.jar | tr ' ' ':'):config schemacrawler.Main "$@"
adriens commented 6 years ago

@sualeh : do there is any chance to get this patch on the v14.19.02 please ?

adriens commented 6 years ago

Great, thanks a lot !