Saturday, 6 August 2016

Run jar file in Unix machine

java -classpath "/devuser/test/test/bismaya/TestPOC/poc.jar:/devuser/test/test/bismaya/TestPOC/ojdbc7.jar" com.edu.test.main.Main

While creating the jar make sure you have selected Main as the class containing main method. Add all the jars to classpath by separating :.

Or

java -classpath `pwd` com.edu.test.main.Main.

In this case all the jars should be present in the current dir.

Or

java -jar jarName.jar --> provided there is no dependency jar is required.

Wednesday, 27 April 2016

Unix commads : Find command example

find . -not -path '*/\.*' -type d \( -iname "$version_id" \) ! -newermt `date +%y%m%d -d "30 days ago"` | tee -a "$log_file"



find . -not -path '*/\.*' -type d \( -iname "$version_id" \) - Find the directory not present in hidden directories

! -newermt `date +%y%m%d -d "30 days ago"`  - Older than 30 days


find . ! -newermt 2016-02-22 ! -type d -delete - Delete the older before the specified date


find . -type l -ls - Find all links


find . -not -path '*/\.*' -type d \( -iname "$version_id" \) ! -newermt `date +%y%m%d -d "63 days ago"` | xargs  rm -rf -- To delete

Upload and Download artifacts from Nexus by cmd line

Download command
-------------------------
mvn -C org.apache.maven.plugins:maven-dependency-plugin:2.4:get
-DremoteRepositories={URL of the repository}
-DgroupId={groupID} -DartifactId={artifactId} -Dversion={version} -Dpackaging=jar -DupdateReleaseInfo=true


Upload command
----------------------
mvn deploy:deploy-file -Dfile=file_FullPath
-DgroupId=*** -DartifactId=*** -Dversion=***
-Dpackaging=jar   -Durl={repo_url} -DrepositoryId={id from setting.xml}

It will download the respective maven plugins to the M2_REPO and then it will upload the artifacts specified. There should be maven installed in the machine where you are trying to upload/download.


Setting.xml
--------------

 <localRepository>C:\M2_REPO</localRepository>

<servers>
  <server>
      <id>releases</id>
      <username>deployment</username>
      <password>deployment123</password>
    </server>
  <server>
        <id>snapshots</id>
        <username>deployment</username>
        <password>deployment123</password>
  </server>



<mirrors>
    <mirror>
      <id>nexus</id>
      <mirrorOf>external:*</mirrorOf>
      <url>http://indlin714:28081/nexus</url>
    </mirror>


<profile>
      <id>nexus</id>
      <!--Enable snapshots for the built in central repo to direct -->
      <!--all requests to nexus via the mirror -->
      <activation>
              <activeByDefault>true</activeByDefault>
         </activation>    
<repositories>
        <repository>
          <id>releases</id>
          <url>http://host:port/nexus/content/repositories/testRepository</url>
          <releases><enabled>true</enabled></releases>
        </repository>
     
  <repository>
         <id>snapshots</id>
          <url>http://host:port/nexus/content/repositories/isr-fnd-public</url>
          <snapshots><enabled>true</enabled></snapshots>
         </repository>

</repositories>
     <pluginRepositories>
        <pluginRepository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>


<activeProfiles>
    <!--make the profile active all the time -->
    <activeProfile>nexus</activeProfile>
  </activeProfiles>











Difference between class level and object locking and static object lock

1) Class level locking will lock entire class, so no other thread can access any of other synchronized blocks. 2) Object locking will lo...