2017年3月29日 星期三

[Java] How to import external library

Import external library into .m2 repository.
mvn install:install-file \
 -Dfile=/home/happy/workspace/Java-WebSocket/dist/java_websocket.jar \
 -DgroupId=org.java-websocket \
 -DartifactId=Java-WebSocket \
 -Dversion=1.3.1 \
 -Dpackaging=jar


Java-WebSocket will install in following folder.
/home/happy/.m2/repository/org/java-websocket/Java-WebSocket/1.3.1


Add the following command tell project which external library will be used.

import org.java_websocket.WebSocketImpl;



Add following script into pom.xml file.

<!-- https://mvnrepository.com/artifact/javax.websocket/javax.websocket-api -->
<dependency>
    <groupId>javax.websocket</groupId>
    <artifactId>javax.websocket-api</artifactId>
    <version>1.1</version>
</dependency>

Execute mvn clean install will install javax.websocket-api.

Reference:

0 意見:

張貼留言