<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 88, comments - 3, trackbacks - 0, articles - 0
      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

    maven項目中有很多本地三方依賴,但是一個一個加入dependency + system scope又很麻煩,又貌似沒有搜索到通配符的成功案例,但是從stackoverflow上看到一個插件addjars-maven-plugin, 可以很好解決這類需求:
        <build>
            
    <plugins>
                
    <plugin>
                    
    <groupId>com.googlecode.addjars-maven-plugin</groupId>
                    
    <artifactId>addjars-maven-plugin</artifactId>
                    
    <version>1.0.2</version>
                    
    <executions>
                        
    <execution>
                            
    <goals>
                                
    <goal>add-jars</goal>
                            
    </goals>
                            
    <configuration>
                                
    <resources>
                                    
    <resource>
                                        
    <directory>${basedir}/../lib</directory>
                                    
    </resource>
                                
    </resources>
                            
    </configuration>
                        
    </execution>
                    
    </executions>
                
    </plugin>
                
    <plugin>
                    
    <groupId>org.apache.maven.plugins</groupId>
                    
    <artifactId>maven-assembly-plugin</artifactId>
                    
    <version>${maven.assembly.version}</version>
                    
    <configuration>
                        
    <descriptorRefs>
                            
    <descriptorRef>jar-with-dependencies</descriptorRef>
                        
    </descriptorRefs>
                        
    <appendAssemblyId>false</appendAssemblyId>
                    
    </configuration>
                    
    <executions>
                        
    <execution>
                            
    <phase>package</phase>
                            
    <goals>
                                
    <goal>single</goal>
                            
    </goals>
                        
    </execution>
                    
    </executions>
                
    </plugin>
            
    </plugins>
        
    </build>

    把項目中依賴的三方jars全放到lib目錄里,就全部會打包到release jar里了

    posted @ 2013-10-30 14:03 Milo的海域 閱讀(1932) | 評論 (0)編輯 收藏

    #include <stdio.h>
    #include 
    <stdlib.h>
    #include 
    <string.h>
    #include 
    <arpa/inet.h>
    #include 
    <inttypes.h>

    uint64_t htonll(uint64_t val) {
        
    return (((uint64_t) htonl(val)) << 32+ htonl(val >> 32);
    }

    uint64_t ntohll(uint64_t val) {
        
    return (((uint64_t) ntohl(val)) << 32+ ntohl(val >> 32);
    }
    int main() {
        uint64_t hll 
    = 0x1122334455667788;
        printf(
    "uint64: %"PRIu64"\n", hll);
        printf(
    "0x%"PRIX64"\n", hll);
        printf(
    "htonll(hll) = 0x%"PRIX64"\n", htonll(hll));
        printf(
    "ntohll(htonll(hll)) = 0x%"PRIX64"\n", ntohll(htonll(hll)));
        printf(
    "ntohll(hll) = 0x%"PRIX64"\n", ntohll(hll)); // no change
        return 1;
    }

    big endian(network byte order), little endian (host byte order in intel arch)

    posted @ 2013-07-23 16:42 Milo的海域 閱讀(3310) | 評論 (0)編輯 收藏

    用jd-eclipse 插件來反編譯java class文件的輸出還是挺nice的,雖然閱讀方便了 但是對debug確造成一定的困擾,主要問題是line number的不match.
    Google了下遇到類似問題的真不少。最終找到了解決方案:
    http://sourceforge.net/projects/realignmentjd/files/
    -----------------

    1. Download JD-Eclipse and JD-GUI - http://java.decompiler.free.fr/ and install.
    2. Put a file realignment.jd.ide.eclipse_1.0.2.jar in eclipse/plugins directory.
        To use Realignment feature it is necessary to open the menu Preferences/General/Editors/File Associations and to select "*.class" file type and to choose "Realignment for JD Class File Editor" for Associated editors.
        Another possibility is the batch realignment after processing JD-GUI. To work properly you must to switch on the property "Display line numbers" in Help/Preferences of JD-GUI.
        To use this feature it is necessary to open the menu Preferences/Java/Decompiler/Batch Realignment and click button "Open dialog". Existing limitation: the realignment is performed only for the methods.
        To work properly it is necessary that the property "Display line numbers" in menu "Preferences/Java/Decompiler" was active.


    JD-Eclipse插件 + realignment 補丁讓優雅的debug class 文件成為可能。

    如果只是為了閱讀class代碼,建議不要用realignment 補丁,這樣會降低代碼的可讀性(會多出大量的空行)
     

    posted @ 2013-02-22 15:01 Milo的海域 閱讀(2051) | 評論 (0)編輯 收藏


    sudo dpkg -l \*erlang\*
    Desired
    =Unknown/Install/Remove/Purge/Hold
    | Status
    =Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
    |/ Err?
    =(none)/Reinst-required (Status,Err: uppercase=bad)
    ||/ Name                          Version                       Description
    +++-
    =============================-=============================-==========================================================================
    ii  erlang                        
    1:14.b.4-dfsg-1ubuntu1        Concurrent, real-time, distributed functional language
    un  erlang-abi-
    13.a               <none>                        (no description available)
    ii  erlang-appmon                 
    1:14.b.4-dfsg-1ubuntu1        Erlang/OTP application monitor
    ii  erlang-asn1                   
    1:14.b.4-dfsg-1ubuntu1        Erlang/OTP modules for ASN.1 support
    rc  erlang-base                   
    1:14.b.4-dfsg-1ubuntu1        Erlang/OTP virtual machine and base applications
    ii  erlang-base-hipe              
    1:14.b.4-dfsg-1ubuntu1        Erlang/OTP HiPE enabled virtual machine and base applications
    ii  erlang-common-test            
    1:14.b.4-dfsg-1ubuntu1        Erlang/OTP application for automated testing
    ii  erlang-corba                  
    1:14.b.4-dfsg-1ubuntu1        Erlang/OTP applications for CORBA support
    ii  erlang-crypto                 
    1:14.b.4-dfsg-1ubuntu1        Erlang/OTP cryptographic modules
    ii  erlang-debugger               
    1:14.b.4-dfsg-1ubuntu1        Erlang/OTP application for debugging and testing
    ii  erlang-dev                    
    1:14.b.4-dfsg-1ubuntu1        Erlang/OTP development libraries and headers
    ii  erlang-dialyzer               
    1:14.b.4-dfsg-1ubuntu1        Erlang/OTP discrepancy analyzer application
    ii  erlang-diameter               
    1:14.b.4-dfsg-1ubuntu1        Erlang/OTP implementation of RFC 3588 protocol
    ii  erlang-doc                    
    1:14.b.4-dfsg-1ubuntu1        Erlang/OTP HTML/PDF documentation
    un  erlang-doc-html               <none>                        (no description available)
    ii  erlang-docbuilder             
    1:14.b.4-dfsg-1ubuntu1        Erlang/OTP application for building HTML documentation
    ii  erlang-edoc                   
    1:14.b.4-dfsg-1ubuntu1        Erlang/OTP module for generating documentation
    ii  erlang-erl-docgen             
    1:14.b.4-dfsg-1ubuntu1        Erlang/OTP documentation stylesheets
    ii  erlang-et                     
    1:14.b.4-dfsg-1ubuntu1        Erlang/OTP event tracer application
    ii  erlang-eunit                  
    1:14.b.4-dfsg-1ubuntu1        Erlang/OTP module for unit testing
    ii  erlang-examples               
    1:14.b.4-dfsg-1ubuntu1        Erlang/OTP application examples
    ii  erlang-gs                     
    1:14.b.4-dfsg-1ubuntu1        Erlang/OTP graphics system
    ii  erlang-ic                     
    1:14.b.4-dfsg-1ubuntu1        Erlang/OTP IDL compiler
    ii  erlang-ic-java                
    1:14.b.4-dfsg-1ubuntu1        Erlang/OTP IDL compiler (Java classes)
    ii  erlang-inets                  
    1:14.b.4-dfsg-1ubuntu1        Erlang/OTP Internet clients and servers
    ii  erlang-inviso                 
    1:14.b.4-dfsg-1ubuntu1        Erlang/OTP trace tool
    ii  erlang-jinterface             
    1:14.b.4-dfsg-1ubuntu1        Java communication tool to Erlang
    ii  erlang-manpages               
    1:14.b.4-dfsg-1ubuntu1        Erlang/OTP manual pages
    ii  erlang-megaco                 
    1:14.b.4-dfsg-1ubuntu1        Erlang/OTP implementation of Megaco/H.248 protocol
    ii  erlang-mnesia                 
    1:14.b.4-dfsg-1ubuntu1        Erlang/OTP distributed relational/object hybrid database
    ii  erlang-mode                   
    1:14.b.4-dfsg-1ubuntu1        Erlang major editing mode for Emacs
    ii  erlang-nox                    
    1:14.b.4-dfsg-1ubuntu1        Erlang/OTP applications that don't require X Window System
    ii  erlang-observer               
    1:14.b.4-dfsg-1ubuntu1        Erlang/OTP application for investigating distributed systems
    ii  erlang-odbc                   
    1:14.b.4-dfsg-1ubuntu1        Erlang/OTP interface to SQL databases
    ii  erlang-os-mon                 
    1:14.b.4-dfsg-1ubuntu1        Erlang/OTP operating system monitor
    ii  erlang-parsetools             
    1:14.b.4-dfsg-1ubuntu1        Erlang/OTP parsing tools
    ii  erlang-percept                
    1:14.b.4-dfsg-1ubuntu1        Erlang/OTP concurrency profiling tool
    ii  erlang-pman                   
    1:14.b.4-dfsg-1ubuntu1        Erlang/OTP process manager
    ii  erlang-public-key             
    1:14.b.4-dfsg-1ubuntu1        Erlang/OTP public key infrastructure
    ii  erlang-reltool                
    1:14.b.4-dfsg-1ubuntu1        Erlang/OTP release management tool
    ii  erlang-runtime-tools          
    1:14.b.4-dfsg-1ubuntu1        Erlang/OTP runtime tracing/debugging tools
    ii  erlang-snmp                   
    1:14.b.4-dfsg-1ubuntu1        Erlang/OTP SNMP applications
    ii  erlang-src                    
    1:14.b.4-dfsg-1ubuntu1        Erlang/OTP applications sources
    ii  erlang-ssh                    
    1:14.b.4-dfsg-1ubuntu1        Erlang/OTP implementation of SSH protocol
    ii  erlang-ssl                    
    1:14.b.4-dfsg-1ubuntu1        Erlang/OTP implementation of SSL
    ii  erlang-syntax-tools           
    1:14.b.4-dfsg-1ubuntu1        Erlang/OTP modules for handling abstract Erlang syntax trees
    ii  erlang-test-server            
    1:14.b.4-dfsg-1ubuntu1        Erlang/OTP server for automated application testing
    ii  erlang-toolbar                
    1:14.b.4-dfsg-1ubuntu1        Erlang/OTP graphical toolbar
    ii  erlang-tools                  
    1:14.b.4-dfsg-1ubuntu1        Erlang/OTP various tools
    ii  erlang-tv                     
    1:14.b.4-dfsg-1ubuntu1        Erlang/OTP table viewer
    ii  erlang-typer                  
    1:14.b.4-dfsg-1ubuntu1        Erlang/OTP code type annotator
    ii  erlang-webtool                
    1:14.b.4-dfsg-1ubuntu1        Erlang/OTP helper for web-based tools
    ii  erlang-x11                    
    1:14.b.4-dfsg-1ubuntu1        Erlang/OTP applications that require X Window System
    ii  erlang-xmerl                  
    1:14.b.4-dfsg-1ubuntu1        Erlang/OTP XML tools

    erlang-dev包含頭文件,erlang-src包含源代碼,erlang-debugger包含調試工具,erlang-base包含虛擬機

    還可以根據package 名字的suffix察看erlang man doc,比如
    man 3erl erlang
    man 3erl mnesia
    man 3erl io

    posted @ 2013-01-15 11:34 Milo的海域 閱讀(676) | 評論 (0)編輯 收藏

    命令行調試erlang程序報錯:
    2> c(hello, [debug_info]).
    {ok
    ,hello}
    3> im().
    Call to i:im/
    0 in application debugger failed.
    ok

    google之原來是erlang-debugger沒裝
    sudo apt-get install erlang-debugger

    然后Monitor窗口就出來了。不過用eclipse 的erlide插件調試也可以。

    posted @ 2013-01-11 17:06 Milo的海域 閱讀(454) | 評論 (0)編輯 收藏

    mvn 執行外部命令
    命令行模式
    mvn exec:exec -Dexec.executable=sh -Dexec.workingdir=./bin -Dexec.args=hello.sh

    配置文件形式
                            <plugin>
                                    <groupId>org.codehaus.mojo</groupId>
                                    <artifactId>exec-maven-plugin</artifactId>
                                    <executions>
                                            <execution>
                                                    <id>test-exec</id>
                                                    <phase>initialize</phase>
                                                    <configuration>
                                                            <executable>sh</executable>
                                                            <workingDirectory>./bin</workingDirectory>
                                                            <arguments>
                                                                    <argument>hello.sh</argument>
                                                            </arguments>
                                                    </configuration>
                                                    <goals>
                                                            <goal>exec</goal>
                                                    </goals>
                                            </execution>
                                    </executions>
                            </plugin>

    mvn 生成java項目
    生成骨架
    mvn archetype:generate -DgroupId=com.abc.product -DartifactId=product -DpackageName=com.abc.product -DarchetypeArtifactId=maven-archetype-quickstart

    轉成eclipse能識別的java 項目
    mvn eclipse:eclipse
    導入eclipse 然后coding

    mvn進行單元測試
                            <plugin>
                                    <groupId>org.apache.maven.plugins</groupId>
                                    <artifactId>maven-surefire-plugin</artifactId>
                                    <version>
    2.12.4</version>
                                    <configuration>
                                            <forkMode>pertest</forkMode>
                                            <excludes>
                                                    <exclude>**/perftest/*.java</exclude>
                                            </excludes>
                                            <systemProperties>
                                                    <property>
                                                            <name>log4j.configuration</name>
                                                            <value>target/test-classes/log4j.properties</value>
                                                    </property>
                                            </systemProperties>
                                    </configuration>
                            </plugin>

    mvn進行code coverage統計
      <reporting>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>emma-maven-plugin</artifactId>
            <version>1.0-alpha-3</version>
            <inherited>true</inherited>
          </plugin>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>surefire-report-maven-plugin</artifactId>
            <inherited>true</inherited>
          </plugin>
        </plugins>
      </reporting>

    mvn生成javadoc
                            <plugin>
                                    <groupId>org.apache.maven.plugins</groupId>
                                    <artifactId>maven-javadoc-plugin</artifactId>
                                    <version>
    2.9</version>
                                    <configuration>
                                            <show>private</show>
                                    </configuration>
                                    <executions>
                                            <execution>
                                                    <id>attach-javadocs</id>
                                                    <goals>
                                                            <goal>javadoc</goal>
                                                            <goal>test-javadoc</goal>
                                                    </goals>
                                                    <phase>site</phase>
                                            </execution>
                                    </executions>
                            </plugin>

    posted @ 2013-01-10 13:33 Milo的海域 閱讀(1288) | 評論 (0)編輯 收藏

    最近項目要用JNI, 涉及到用java.library.path這個參數,開始以為只要ldconfig能識別到的so文件java 一定能找到,可惜并不是這樣。。
    要想java程序找到共享庫還是要在執行java程序的時候指定java.library.path,用eclipse的話可以設置如下:
    Properties->Run/Debug settings->Arguments->VM arguments
    -----------------------------------------
    -Djava.library.path=/home/miaoyachun/workspace/JNIC/Release
    這個是傳統的方式,google了下有個tricky的方式讓程序動態修改java.library.path
        private static void loadJNILibDynamically() {
            
    try {
                System.setProperty(
    "java.library.path", System.getProperty("java.library.path")
                        
    + ":/home/miaoyachun/workspace/JNIC/Release/");
                Field fieldSysPath 
    = ClassLoader.class.getDeclaredField("sys_paths");
                fieldSysPath.setAccessible(
    true);
                fieldSysPath.set(
    nullnull);

                System.loadLibrary(
    "JNIC");
            } 
    catch (Exception e) {
                
    // do nothing for exception
            }
        }

    事實上linux下還有個環境變量LD_LIBRARY_PATH,如果lib能在這個path里找到,java.library.path就不用配置了,而且不需要關心lib之間依賴的問題。java.library.path在這方面就弱很多,比如lib依賴其他目錄的lib等。

    posted @ 2012-12-06 11:05 Milo的海域 閱讀(6864) | 評論 (0)編輯 收藏

    今天有同事反應一個網絡現象,一個多網卡環境,發給eth1的數據包都被eth0接收了。
    第一印象是arp的問題。Google了下得到了確認,有個相關的kernal參數:
    arp_ignore - INTEGER
    Define different modes for sending replies in response to
    received ARP requests that resolve local target IP addresses:
    0 - (default): reply for any local target IP address, configured
    on any interface
    1 - reply only if the target IP address is local address
    configured on the incoming interface
    2 - reply only if the target IP address is local address
    configured on the incoming interface and both with the
    sender's IP address are part from same subnet on this interface
    3 - do not reply for local addresses configured with scope host,
    only resolutions for global and link addresses are replied
    4-7 - reserved
    8 - do not reply for all local addresses
    默認是0,解決這個問題需要配置為1

    臨時配置下
    sysctl -w net.ipv4.conf.all.arp_ignore=1

    持久配置
    sysctl -w net.ipv4.conf.all.arp_ignore=1
    echo 'net.ipv4.conf.all.arp_ignore
    =1' >> /etc/sysctl.conf

    這個弄好可以重啟network服務來確保其他機器更新arp cache,如果不方便重啟network,自己手動敲arping命令,比如
    arping -q -A -c 1 -I eth1 10.197.24.177
    這個命令是在 /etc/sysconfig/network-scripts/ifup-eth里看到的

    如果機器比較少,也可以直接用arp -d 來刪除相關的cache,建議上面的那種發廣播的方式。

    posted @ 2012-11-27 17:16 Milo的海域 閱讀(663) | 評論 (0)編輯 收藏

    檢測磁盤相關信息   
        smartctl -a /dev/sda
    (smartctl工具來自smartmontools, 可以apt-get install smartmontools來安裝)

    檢測所有raid設備
        mdadm -Ds

    檢測具體raid設備信息
        mdadm -D /dev/md0

    創建raid設備
       mdadm --create --verbose /dev/md0 --level=raid0 --raid-devices=8 /dev/sdd /dev/sdc /dev/sdf /dev/sde /dev/sdg /dev/sdh /dev/sdi /dev/sdj

    停止raid設備
        mdadm -S /dev/md0

    格式化raid設備
        mkfs -t xfs -f /dev/md0

    掛載raid設備
       mount -t xfs /dev/md0 /raid

    切換raid模式的步驟
        1. umount if mounted : umount /raid
        2. stop raid device:  mdadm -S /dev/md0
        3. create raid: mdadm --create ...
        4. update /etc/mdadm.conf with output of 'mdadm -Ds', 用來開機自動組raid
        5. update /etc/fstab, 如果需要開機自動mount

    Ref:
    http://francs3.blog.163.com/blog/static/40576727201212145744783/
    http://hi.baidu.com/powersaven/item/1da2dc147a8be2e25f53b19e

    posted @ 2012-11-07 13:23 Milo的海域 閱讀(265) | 評論 (0)編輯 收藏

    關于alternatives的用法


    alternatives --install /usr/bin/java java /opt/jdk1
    .5.0_22/bin/java 15000
    alternatives --install /usr/bin/javac javac /opt/jdk1
    .5.0_22/bin/javac 15000
    alternatives --config java
    alternatives --config javac
    最近切換桌面環境到ubuntu, 發現alternatives這個工具改名了:update-alternatives
    用法還是一樣的。。

    posted @ 2012-10-26 13:31 Milo的海域 閱讀(813) | 評論 (0)編輯 收藏

    僅列出標題
    共9頁: 上一頁 1 2 3 4 5 6 7 8 9 下一頁 
    主站蜘蛛池模板: 老湿机一区午夜精品免费福利| 国产在线观看免费视频软件| 亚洲精品第一国产综合精品99| 久久嫩草影院免费看夜色| 亚洲综合在线视频| 日韩中文无码有码免费视频| 中文字幕视频免费在线观看| 亚洲国产高清在线精品一区| 91嫩草亚洲精品| xvideos亚洲永久网址| 久久久高清日本道免费观看| 亚洲av无码一区二区三区人妖| 国产av无码专区亚洲av桃花庵| 毛片免费视频在线观看| 青柠影视在线观看免费高清| 亚洲日产乱码一二三区别 | 2021国产精品成人免费视频| 亚洲国产AV一区二区三区四区| 日本免费人成在线网站| 一级黄色毛片免费看| 亚洲av乱码一区二区三区| 亚洲欧洲日产国码av系列天堂| 成年男女男精品免费视频网站| fc2免费人成为视频| 亚洲日本成本人观看| 亚洲国产精品无码久久久秋霞2| 免费a级毛片无码a∨蜜芽试看| 国产成人+综合亚洲+天堂| 亚洲精品一卡2卡3卡三卡四卡| 深夜国产福利99亚洲视频| 999久久久免费精品国产| 免费看少妇高潮成人片| 色偷偷亚洲男人天堂| 亚洲剧情在线观看| 亚洲国产一区二区a毛片| 久久亚洲国产精品123区| 国产无遮挡又黄又爽免费视频| 日本人的色道免费网站| 日韩在线永久免费播放| 免费无码作爱视频| 黄色视频在线免费观看|