Officially Java and Bedrock Edition cannot be played together since both of them are not compatible. However, according to PCGamesN, there's an unofficial third-party plugin called GeyserMC players can use for cross-playing among these editions.