1

I have a small Java project built with the jGRASP IDE on Windows, with all the files in a single flat directory. Among them is an external jar file: pdfbox-app.jar. Compilation and access to that library succeeds if I add the file to the project CLASSPATH with an absolute address.

But the project build then breaks if this is distributed to other people (via GitHub) and they put the code in any different directory structure. So it would be preferred to provide a relative address on the CLASSPATH. However,nothing I've tried to add in that vein reliably succeeds. Things I've tried to add to the project classpath:

pdfbox-app.jar
\pdfbox-app.jar
.\pdfbox-app.jar
%<PROJECT_PATH>\pdfbox-app.jar

I've also tried to add command-line compile arguments:

-cp ".;.\pdfbox-app.jar"

What would work here for a relative-address inclusion on the jGRASP project CLASSPATH?

Daniel R. Collins
  • 893
  • 1
  • 8
  • 22

1 Answers1

2

Any of those classpath additions should work, assuming that pdfbox-app.jar is located at the root of your common classpath (the directory containing the package roots), or for %<PROJECT_PATH>, the directory containing the project file itself if that is different. If it is not, then you need a relative path to one of those locations.

The flags should also work, but for Java flags you need to add them as "Flags2 or Args2" for the "Compile", "Run", and "Debug" commands using "Settings" -> "Compiler Settings". Command line arguments are arguments to your program only.

lbarowski
  • 411
  • 3
  • 2
  • As noted, none of these options work (despite pdfbox-app.jar residing in the single flat directory with the rest of the project). I tried putting the indicated arguments under ARGS2 and that made no difference, either. – Daniel R. Collins Sep 24 '22 at 05:11
  • Send a bug report through jGRASP "Help" -> "Report a Bug" that includes your email address, and I'll get back to you. Also, if you turn on "Settings" -> "Verbose Messages", the "actual command sent" line in the compile and run output will show you the commands, and the working directory will also be reported, so you can see if something is not right there. – lbarowski Sep 25 '22 at 00:01
  • Very cool, thanks for that. Actually with the verbose messages I think I see the issue: the working directory for the "Compile all files in project" command isn't the project folder, but rather C:\Users\Daniel\AppData\Local\Temp (a normally hidden folder in the Windows user directory on a different drive). Compiling a single file at a time correctly sets the working directory to the project folder. Do you know of any way to fix that? Still a bug? – Daniel R. Collins Sep 26 '22 at 02:47
  • Anyway, I just sent in a bug report. Thanks for looking at this! – Daniel R. Collins Sep 26 '22 at 03:06
  • 2
    For anyone else reading this, I have confirmed as a bug which will be fixed as of jGRASP 2.0.6_11 Beta 2. – lbarowski Sep 26 '22 at 05:48
  • Got it working for now with the compile flag workaround -cp %%:%%/pdfbox-app.jar. Looking forward to the bug fix in the next release. Thanks a bunch! – Daniel R. Collins Sep 26 '22 at 15:47