12

is there JRE 1.6 available in some public Maven repository we could proxy in our Nexus?

if not, can somebody please provide a hint on how to deploy JRE to a Maven repository?

Alex
  • 2,589
  • 3
  • 35
  • 44
  • This is a strange requirement. `JRE` is not exactly a library like `jar`. I am not sure if it is possible at all. – Petar Minchev Dec 16 '11 at 21:47
  • How exactly would you expect this to work? – Thorbjørn Ravn Andersen Dec 16 '11 at 21:49
  • 1
    I need to put JRE into the distributive in my maven build. I could just download it as a part of the build process, but there's no guarantee that Oracle will keep JRE distributions in the same locations... that's why I was thinking about putting JRE into my maven repository (since JRE is a binary thing after all :) ). maybe this is a bad idea and auto-download from Oracle site would be better... – Alex Dec 16 '11 at 22:53
  • This requirement smacks of bizarro. Are you trying to say your deployable should be able to work on systems without a JRE installed? – Perception Dec 16 '11 at 23:04
  • sorry for not being clear enough in the original request. what I need to have is - create a distributive with my web application, plus put Jetty server there, plus JRE. the goal is to simplify user's life: just download my ZIP distr, unpack and run some batch file, which will start the Jetty using the packaged JRE (to avoid a problem when there's no JRE installed so the app can't run). – Alex Dec 16 '11 at 23:07
  • btw, I found this solution to download files during Maven builds: http://stackoverflow.com/a/5754271/477655 (use wagon-maven-plugin) – Alex Dec 16 '11 at 23:09
  • It would help to know what platform you are building for. – Zac Thompson Dec 17 '11 at 06:06
  • my app needs to work on 3 main platforms: Linux, Windows, MacOS. – Alex Dec 17 '11 at 20:38
  • One of the problems distributing the JRE with your software is that you may need to sign some sort of paperwork to Oracle if they allow you to redistribute their packages. – feniix Dec 17 '11 at 23:54

3 Answers3

13

here's the solution I found:

  • Zip the JREs (jre-linux32-1.6.0.23.zip and jre-jre-win32-1.6.0.zip in my case).
  • Upload them to your Nexus repository through web UI (or deploy manually with "mvn"), set the artifact parameters: groupid="oracle" artifactid="jre-win32" / "jre-linux32", set the right version and packaging type "zip".
  • modify your pom.xml to download and unzip the dependency during the build (I bound it to "prepare-package" phase).

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.4</version>
                <executions>
                    <execution>
                        <id>copy</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>oracle</groupId>
                                    <artifactId>jre-win32</artifactId>
                                    <version>1.6.0.23</version>
                                    <type>zip</type>
                                    <overWrite>false</overWrite>
                                    <outputDirectory>${project.build.directory}/alternateLocation</outputDirectory>
                                    <!--<destFileName>optional-new-name.jar</destFileName>-->
                                </artifactItem>
                                <artifactItem>
                                    <groupId>oracle</groupId>
                                    <artifactId>jre-linux32</artifactId>
                                    <version>1.6.0.23</version>
                                    <type>zip</type>
                                    <overWrite>false</overWrite>
                                    <outputDirectory>${project.build.directory}/alternateLocation</outputDirectory>
                                    <!--<destFileName>optional-new-name.jar</destFileName>-->
                                </artifactItem>
                            </artifactItems>
                            <outputDirectory>${project.build.directory}/wars</outputDirectory>
                            <overWriteReleases>false</overWriteReleases>
                            <overWriteSnapshots>true</overWriteSnapshots>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    

that's it. The JRE will be downloaded and extracted to target\alternateLocation folder.

you can use "copy" goal instead of "unpack" if you want to only copy the ZIP files without extracting them.

Alex
  • 2,589
  • 3
  • 35
  • 44
  • 2
    Why didn't you use classifiers instead of artifacts ? After all classifiers are precisely here to distinguish between different architectures. – Riduidel Feb 04 '13 at 14:32
1

Your requirement is somewhat valid use-case. But IMHO, putting it in to a maven-repo is not the way to do it.

Other applications, achieve this requirement by getting the executables directly from the provider. For an example build servers like Hudson/Jenkins need to download Java/Maven upon users selection and AFAIR Jenkins download them directly from the Oracle site. (Since oracle asks you to login before download they use SSO mechanism). A similar solution along those path would be suitable for you.

Even if you host your JRE in m2-repo there are certain security problems. JRE is a sensitive program. Even if you say that you have hosted the same JRE from oracle, I would rather download it from oracle.

  • Thank you for the comment. I'm inclining to download it from Oracle indeed, but they only have RPM and EXE files, while I'd need a ZIP version. Another option for me will be using JavaWebStart to deliver the app instead of creating a distributive, but that's a different topic. – Alex Dec 17 '11 at 03:53
-2

Here you can read how to install a jar into a maven repo. But why do you want to install the JRE jars in a maven repo?

Marc-Christian Schulze
  • 3,154
  • 3
  • 35
  • 45