Steven Matthews
Steven Matthews

Reputation: 11325

Compiling a single Java file

Relatively new to Java - I just one to update ONE file inside a JAR file. I've decompiled the JAR, and have access to the Java file.

I am trying to use javac, however when I am using it, it throws errors as it doesn't have references to various dependencies.

Do I need to compile everything to get rid of these? Is there a simple way to just compile the one file?

javac MessageNotificationService.java
...

MessageNotificationService.java:108: error: cannot find symbol
        List<EmailNotification> pendingEmails = this.messageDao.findPendingNotification("merchant", "new_message");
             ^
  symbol:   class EmailNotification
  location: class MessageNotificationService
MessageNotificationService.java:111: error: cannot find symbol
            List<Long> ids = pendingEmails.stream().map(EmailNotification::getId).collect(Collectors.toList());
                                                        ^
  symbol:   variable EmailNotification
  location: class MessageNotificationService
MessageNotificationService.java:182: error: cannot find symbol
        for (EmailNotification notification : pendingEmails) {
             ^
  symbol:   class EmailNotification
  location: class MessageNotificationService
39 errors

Sorry if this is a basic question - all of the search results on this seem to be for self-contained files that don't have errors like this.

Upvotes: 0

Views: 1119

Answers (1)

Steven Matthews
Steven Matthews

Reputation: 11325

As far as I can tell, you just point to the old JAR file

javac -cp "./old-jar-file-1.0.0.jar" ./location-of-file/MessageNotificationService.java

Upvotes: 1

Related Questions