Author Topic: Why isn't project-compile using my class path?  (Read 2398 times)

rygaard

  • Community Member
  • Posts: 63
  • Hero Points: 1
Re: Why isn't project-compile using my class path?
« Reply #15 on: September 02, 2022, 04:58:31 PM »
Based on your latest post, I updated my experiment so that the manifest uses Unix newline characters instead of Windows newline characters.  The multi-line version of the Class-Path attribute works just fine.

Clarification:  When I used the new multi-line version of the Class-Path attribute, I did not receive any error messages concerning the manifest file.  However, the javac command that I used (outside of SlickEdit) still could not find the classes in my class path.

Correction:  This post is incorrect.  With the new multi-line version of the Class-Path field, I get this error:
Quote
error: error reading D:\SystemBlend\classpath.jar; invalid header field (line 3)
« Last Edit: September 02, 2022, 09:34:53 PM by rygaard »

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1818
  • Hero Points: 151
Re: Why isn't project-compile using my class path?
« Reply #16 on: September 02, 2022, 05:13:42 PM »
That's definitely not right.  Looks like it's using a function where the line endings depend on settings.

Attached is a new version of projconv.e   Load that up.  It should fix that problem.  (and I removed the part where it leaves the manifest in the temp directory, so this can serve as a fix). 

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1818
  • Hero Points: 151
Re: Why isn't project-compile using my class path?
« Reply #17 on: September 02, 2022, 05:17:40 PM »
And I just saw your edit.  I've got your manifest, so I'll see if I can find anything else wrong with it.

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1818
  • Hero Points: 151
Re: Why isn't project-compile using my class path?
« Reply #18 on: September 02, 2022, 05:29:58 PM »
One problem I see is lines aren't being broken at 72 characters per the spec.  For the compilation failures you're getting, does it look like it's missing definitions from one of the classpaths whose length is > 72 chars in the manifest?

My test projects with lots of class files have some entries that break this rule, but because they use some copies of the same jars in different places to pad out the number of classpath entries, it masks the problem so I didn't get any compilation errors.

Edit: actually, that doesn't seem to be the problem, playing with the paths more, the length doesn't seem to be a problem, or if it is, it's at a limit I (and your manifest) haven't reached. I think the 72 char limitation is for the MANIFEST.MF file that's actually packed in the jar file, and jar is more lenient and does conversions on manifests passed into it.   But I haven't backed that up with a doc yet, it just seems to be the behavior.
« Last Edit: September 02, 2022, 06:30:45 PM by patrick »

rygaard

  • Community Member
  • Posts: 63
  • Hero Points: 1
Re: Why isn't project-compile using my class path?
« Reply #19 on: September 02, 2022, 08:26:28 PM »
I'm getting similar behavior outside of SlickEdit.  This is the experiment I am running (completely outside of SlickEdit):

  • Create a manifest file with the classpath.  All of the entries in the classpath are relative to my project root directory.  Some of the entries are directories, and some of the entries are JAR files.
  • Create a JAR that only has a manifest, and the manifest uses the classpath from the previous step.
  • cd to my project root directory
  • Execute the javac command.  For the classpath, the only entry is the JAR file.

When I run this experiment, all references in my source code to classes bundled in the JAR files are properly resolved.  Classes that are in .class files below one of the classpath directories are not resolved.

I confirmed that the .class files do exist, and that the directories in the manifest's classpath are correct.

CORRECTION:  I had an error in my experiment.  With the error corrected, I get this error:
Quote
error: error reading path\to\classpath.jar; invalid header field (line 3)
and nothing else.
« Last Edit: September 02, 2022, 09:37:25 PM by rygaard »

rygaard

  • Community Member
  • Posts: 63
  • Hero Points: 1
Re: Why isn't project-compile using my class path?
« Reply #20 on: September 02, 2022, 09:35:24 PM »
Also see the correction to my earlier post.

rygaard

  • Community Member
  • Posts: 63
  • Hero Points: 1
Re: Why isn't project-compile using my class path?
« Reply #21 on: September 02, 2022, 10:35:53 PM »
As I reported in an earlier post, when I try to compile within SlickEdit, I get this error message in the Output tab:
Quote
EXEC jar.exe cfm "C:\Users\loginname\AppData\Local\Temp\se_classpath1852.jar" "C:\Users\loginname\AppData\Local\Temp\manifest1852.txt"
java.io.IOException: invalid header field (line 1)
   at java.base/java.util.jar.Attributes.read(Attributes.java:411)
   at java.base/java.util.jar.Manifest.read(Manifest.java:290)
   at java.base/java.util.jar.Manifest.<init>(Manifest.java:100)
   at java.base/java.util.jar.Manifest.<init>(Manifest.java:76)
   at jdk.jartool/sun.tools.jar.Main.run(Main.java:268)
   at jdk.jartool/sun.tools.jar.Main.main(Main.java:1665)

I get the exact same error message when I try to re-create the steps that SlickEdit is taking, except completely outside of SlickEdit.

In my earlier experiments, I was not calling the jar command.  Instead, I was creating the JAR file from within Java using a java.util.zip.ZipOutputStream, and writing the manifest directly into a java.util.zip.ZipEntry.  This effectively avoided some error checking provided by the jar command, so the error occurred later during compile.

So it looks like this approach does not work with the Java I have set up on my machines.  This command-line output shows the Java version:
Quote
C:\>jar --version
jar 17.0.2

C:\>java --version
openjdk 17.0.2 2022-01-18
OpenJDK Runtime Environment (build 17.0.2+8-86)
OpenJDK 64-Bit Server VM (build 17.0.2+8-86, mixed mode, sharing)

C:\>javac --version
javac 17.0.2

C:\>

rygaard

  • Community Member
  • Posts: 63
  • Hero Points: 1
Re: Why isn't project-compile using my class path?
« Reply #22 on: September 03, 2022, 06:48:19 PM »
The attached .zip file shows how I reproduce the bug outside of SlickEdit.  To reproduce it:
  • Either go to a machine with Java 17.0.2 or load Java 17.0.2
  • Unzip the attached .zip file in any convenient location
  • Run go.bat
The .zip file contains just two files, in this directory structure:
      JarClassPath/
           go.bat (one line)
           classpath.txt (three lines)

rygaard

  • Community Member
  • Posts: 63
  • Hero Points: 1
Re: Why isn't project-compile using my class path?
« Reply #23 on: September 03, 2022, 11:40:01 PM »
A colleague helped me diagnose the problem.

The manifest's classpath file should look like this:
Quote
Class-Path: Subdirectory1/
  Subdirectory2/

The manifest's classpath file should not look like this:
Quote
Class-Path:
  Subdirectory1/
  Subdirectory2/

The difference is line 1:  It must have a classpath entry.

Also, there was another error in my previous post:  Each continuation line must begin with 2 spaces, not 1.

I hope there is a way you can send me a hot fix for this soon, because my development is considerably slower (and rather frustrating) because of this issue.
« Last Edit: September 03, 2022, 11:44:39 PM by rygaard »

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1818
  • Hero Points: 151
Re: Why isn't project-compile using my class path?
« Reply #24 on: September 06, 2022, 01:26:31 PM »
I've attached an updated projconv.e that puts the first entry on the line with the attribute name.  Load that, and give it a shot.

While these changes doesn't break any of my existing test projects, I haven't reproduced what you're describing either.  I'm changing over one of the projects to have more classpath directories to see if that makes a difference. 

Just to be paranoid, what JDK are you using?

rygaard

  • Community Member
  • Posts: 63
  • Hero Points: 1
Re: Why isn't project-compile using my class path?
« Reply #25 on: September 06, 2022, 04:01:08 PM »
Quote
C:\>jar --version
jar 17.0.2

C:\>java --version
openjdk 17.0.2 2022-01-18
OpenJDK Runtime Environment (build 17.0.2+8-86)
OpenJDK 64-Bit Server VM (build 17.0.2+8-86, mixed mode, sharing)

C:\>javac --version
javac 17.0.2

C:\>

rygaard

  • Community Member
  • Posts: 63
  • Hero Points: 1
Re: Why isn't project-compile using my class path?
« Reply #26 on: September 07, 2022, 01:35:15 PM »
 ;D

Oh, Happy!  Happy!  Joy!  Joy!

That fixed it!

 ;D

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1818
  • Hero Points: 151
Re: Why isn't project-compile using my class path?
« Reply #27 on: September 07, 2022, 04:04:41 PM »
Good.  I'm checking in fixes for that today.  Let me know if you run into any other problems.

rygaard

  • Community Member
  • Posts: 63
  • Hero Points: 1
Re: Why isn't project-compile using my class path?
« Reply #28 on: September 07, 2022, 09:54:08 PM »
Patrick,

Thank you so much for your support.  As you noticed, I made some errors that confused the situation, and I apologize for that.

Thanks again!
« Last Edit: September 07, 2022, 10:12:25 PM by rygaard »