Installer installer = new ZipURLInstaller(
"https://download.eclipse.org/ee4j/glassfish/glassfish-6.2.5.zip",
"target/downloads", "target/extracts");
installer.install();
InstalledLocalContainer container = new GlassFish6xInstalledLocalContainer(
new GlassFish6xStandaloneConfiguration("target/glassfish6x"));
container.setHome(installer.getHome());
// Set the hostname to a running, remote GlassFish 6.0 instance
// for the GlassFish6xInstalledLocalDeployer to perform a remote deployment
container.getConfiguration.setProperty(GeneralPropertySet.HOSTNAME, "10.0.2.15");
// Instruct the GlassFish asadmin to upload the file to the remote server
container.getConfiguration.setProperty(
GlassFishPropertySet.DEPLOY_ARG_PREFIX + "remoteUpload", "--upload=true");
DeployableFactory factory = new DefaultDeployableFactory();
WAR war = factory.createDeployable(container.getId(), "path/to/my.war",
DeployableType.WAR);
// Create dummy local configuration and deploy remotely
container.getConfiguration().configure(container);
Deployer deployer = new GlassFish6xInstalledLocalDeployer(container);
deployer.deploy(war);