Maven Eclipse set compiler JDK compliance level








The maven project/module created in Eclipse set JAVA 1.5 as the default. You cannot change it via Eclipse project settings (as it will be reverted back to 1.5) when you run Maven -> Update Project. To solve this, you can add the following to the pom.xml:
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.3</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
    </plugins>
</build>
Or, if you have hierarchical project with modules, you can put it into pluginManagement of the parent project's pom.xml:
<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.3</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
</build>
All the descendant modules will inherit the compiler settings from the parent.

NOTE:

In Eclipse, if the project packaging is pom the compiler settings will not get updated using the above. You will need to change packaging to jar then Update the Maven projects. You can revert back to pom after the compiler settings has been changed.


Install pixelmed jar files into local maven repository








  • The script to install the pixelmed jar files to local maven repository:
    #!/bin/bash
    
    repo=/path/to/mvn-repo
    dir=/path/to/pixelmed
    
    name=pixelmed-codec
    version=20141206
    mvn install:install-file \
        -Dfile=${dir}/pixelmed_codec.jar \
        -DgroupId=com.pixelmed \
        -DartifactId=pixelmed-codec \
        -Dname=pixelmed_codec.jar \
        -Dversion=${version} \
        -Dpackaging=jar \
        -DperformRelease=true \
        -DcreateChecksum=true \
        -DgeneratePom=true \
        -DlocalRepositoryPath=${repo}
    
    name=pixelmed-aiviewer
    version=20150512
    mvn install:install-file \
        -Dfile=${dir}/aiviewer.jar \
        -DgroupId=com.pixelmed \
        -DartifactId=pixelmed-aiviewer \
        -Dname=aiviewer.jar \
        -Dversion=${version} \
        -Dpackaging=jar \
        -DperformRelease=true \
        -DcreateChecksum=true \
        -DgeneratePom=true \
        -DlocalRepositoryPath=${repo}
    
    name=pixelmed
    version=20150512
    mvn install:install-file \
        -Dfile=${dir}/pixelmed.jar \
        -DgroupId=com.pixelmed \
        -DartifactId=pixelmed \
        -Dname=pixelmed.jar \
        -Dversion=${version} \
        -Dversion=${version} \
        -Dpackaging=jar \
        -DperformRelease=true \
        -DcreateChecksum=true \
        -DpomFile=/path/to/pixelmed.pom.xml \
        -DlocalRepositoryPath=${repo}
    
  • The pom.xml for pixelmed.jar
    <?xml version="1.0" encoding="UTF-8"?>
    <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <modelVersion>4.0.0</modelVersion>
      <groupId>com.pixelmed</groupId>
      <artifactId>pixelmed</artifactId>
      <version>20150512</version>
      <description>PixelMed Java DICOM library.</description>
      <dependencies>
        <dependency>
          <groupId>javax.jmdns</groupId>
          <artifactId>jmdns</artifactId>
          <version>3.4.1</version>
        </dependency>
        <dependency>
          <groupId>org.hsqldb</groupId>
          <artifactId>hsqldb</artifactId>
          <version>2.3.2</version>
        </dependency>
        <dependency>
          <groupId>java3d</groupId>
          <artifactId>vecmath</artifactId>
          <version>1.3.1</version>
        </dependency>
        <dependency>
          <groupId>commons-net</groupId>
          <artifactId>commons-net</artifactId>
          <version>3.3</version>
        </dependency>
        <dependency>
          <groupId>commons-codec</groupId>
          <artifactId>commons-codec</artifactId>
          <version>1.10</version>
        </dependency>
        <dependency>
          <groupId>org.apache.commons</groupId>
          <artifactId>commons-compress</artifactId>
          <version>1.9</version>
        </dependency>
      </dependencies>
    </project>
    



Python: read string from file








with open ("file.txt", "r") as file:
    # merge to a single line
    data=file.read().replace('\n', '')