rjzii
rjzii

Reputation: 14543

How can you prevent short file names (8.3 format) in javac output?

I recently ran into an unusual issue with compiling an internal application, as you can see from the following, there is a mixture of file names that are using the short format as well as the long format:

-rwxrwxr-x 1 jenkins jenkins  472 Jan  5 15:32 BadDelimiterException.class
-rwxrwxr-x 1 jenkins jenkins  460 Jan  5 15:32 BadQuoteException.class
-rwxrwxr-x 1 jenkins jenkins 1711 Jan  5 15:32 SC7B38~1.CLA
-rwxrwxr-x 1 jenkins jenkins 1023 Jan  5 15:32 SCHOLA~4.CLA

Unfortunately these files are in a JAR file and javac is complaining about not being able to find the classes when a build is done on Linux and the JAR file being used as a reference is unlikely to get rebuilt any time soon. Currently I've been going through and manually renaming the short format file names to the correct name, but this is time consuming and doesn't provide full coverage of the files in the JAR. Is there a javac command line switch that will either allow it to recognize the files, or conversely, one that will prevent it from occurring in the first place?

Upvotes: 1

Views: 207

Answers (2)

Stephen C
Stephen C

Reputation: 719004

How can you prevent short file names (8.3 format) in javac output?

It is not javac that is responsible. The problem is that somewhere in the lifetime of the files, they have been copied using FAT filesystem drivers that are not VFAT aware. This has resulted in the loss of the extended file attributes containing the full filenames.

There is no cure for this once it has happened. If you want to prevent it happening again, you will need to figure out where the machine with the old filesystem is, and avoid using it to hold or copy Java-related files.

Upvotes: 1

NPE
NPE

Reputation: 500495

It is not totally clear to me how these came about (it's clear that there was a FAT filesystem involved at some stage, but beyond that it's hard to say).

I doubt you'll be able to get java to recognize these, and load them automatically. You probably could write your own class loader that would take care of that. However, doing so would require a non-trivial amount of effort, and it's unclear how well that would work anyway.

My suggestion would be to use javap to help with the manual renaming that you've been doing.

Let's say you have a file called SCHOLA~4.CLA. If you rename it to SCHOLA~4.class and put it somewhere on the classpath, the following command:

javap SCHOLA~4

would print out the name of the class. This should help in at least partially automating the process of renaming the files.

Upvotes: 2

Related Questions