尊龙凯时人生就是博

ÔÚLinuxϵͳÉÏʹÓÃIntelliJ IDEA¾ÙÐÐÇø¿éÁ´¿ª·¢µÄÉèÖÃÒªÁì

ÔÚlinuxϵͳÉÏʹÓÃintellij idea¾ÙÐÐÇø¿éÁ´¿ª·¢µÄÉèÖÃÒªÁì

СÐò£º

Ëæ×ÅÇø¿éÁ´ÊÖÒÕÔÚ½ðÈÚ¡¢¹©Ó¦Á´ÖÎÀí¡¢Ò½ÁƵÈÁìÓòµÄÆÕ±éÓ¦Ó㬹ØÓÚÇø¿éÁ´¿ª·¢¹¤¾ßµÄÐèÇóÒ²Ô½À´Ô½´ó¡£¶øIntelliJ IDEA×÷Ϊһ¸ö¹¦Ð§Ç¿Ê¢µÄ¼¯³É¿ª·¢ÇéÐΣ¬²»µ«¿ÉÒÔÌṩ¸»ºñµÄ²å¼þ£¬»¹ÄÜÒÔ±ã½ÝµÄ·½·¨Ö§³ÖÖÖÖÖ±à³ÌÓïÑԵĿª·¢¡£±¾ÎĽ«ÏÈÈÝÔõÑùÔÚlinuxϵͳÉÏʹÓÃintellij idea¾ÙÐÐÇø¿éÁ´¿ª·¢µÄÉèÖÃÒªÁ죬²¢¸½ÓдúÂëʾÀý¡£

°ì·¨Ò»£º×°ÖÃIntelliJ IDEA

Ê×ÏÈ£¬ÎÒÃÇÐèÒªÏÈÏÂÔز¢×°ÖÃIntelliJ IDEA¡£ÔÚLinuxϵͳÉÏ£¬Äú¿ÉÒÔÇ°ÍùJetBrainsµÄ¹Ù·½ÍøÕ¾£¨https://www.jetbrains.com/idea/£©ÏÂÔØÊÊÓÃÓÚLinuxµÄIntelliJ IDEA°æ±¾¡£ÏÂÔØÍê³Éºó£¬½âѹËõ×°Öðü£¬²¢½«½âѹºóµÄÎļþ¼ÐÒƶ¯µ½ÄúÏ£Íû×°ÖõÄĿ¼¡£

°ì·¨¶þ£º×°ÖÃJava JDK

ÓÉÓÚIntelliJ IDEAÊÇ»ùÓÚJava¿ª·¢µÄ£¬Òò´ËÔÚʹÓÃ֮ǰ£¬ÐèҪȷ±£ÏµÍ³ÉÏÒѾ­×°ÖÃÁËJava JDK¡£Äú¿ÉÒÔͨ¹ýÖ´ÐÐÒÔÏÂÏÂÁîÀ´¼ì²éÊÇ·ñÒѾ­×°ÖÃÁËJava JDK£º

java -version

µÇ¼ºó¸´ÖÆ

ÈôÊÇÒѾ­×°ÖÃÁËJava JDK£¬Ôò»áÏÔʾJavaµÄ°æ±¾ºÅ¡£ÈôÊÇûÓÐ×°Öã¬ÔòÐèÒªÔÚÖÕ¶ËÖ´ÐÐÒÔÏÂÏÂÁî¾ÙÐÐ×°Öãº

sudo apt update
sudo apt install default-jdk

µÇ¼ºó¸´ÖÆ

°ì·¨Èý£º×°Öò¢ÉèÖÃGradle

GradleÊÇÒ»¸öºÜÊÇÊ¢ÐеĹ¹½¨¹¤¾ß£¬ÓÃÓÚÖÎÀíÒÀÀµÏîºÍ¹¹½¨ÏîÄ¿¡£ÔÚʹÓÃGradle֮ǰ£¬ÐèÒªÏÈ×°Öò¢ÉèÖÃËü¡£Äú¿ÉÒÔÖ´ÐÐÒÔÏÂÏÂÁî¾ÙÐÐ×°Öãº

sudo apt install gradle

µÇ¼ºó¸´ÖÆ

×°ÖÃÍê³Éºó£¬Ê¹ÓÃÒÔÏÂÏÂÁî¼ì²éGradleÊÇ·ñ×°ÖÃÀֳɣº

gradle -v

µÇ¼ºó¸´ÖÆ

½ÓÏÂÀ´£¬ÐèÒªÉèÖÃGradleµÄÇéÐαäÁ¿¡£·­¿ªÖնˣ¬ÊäÈëÒÔÏÂÏÂÁî±à¼­ÉèÖÃÎļþ£º

sudo nano /etc/profile.d/gradle.sh

µÇ¼ºó¸´ÖÆ

Ôڱ༭Æ÷ÖÐÊäÈëÒÔÏÂÄÚÈÝ£º

export PATH=$PATH:/opt/gradle/gradle-<version>/bin

µÇ¼ºó¸´ÖÆ

½« Ì滻ΪÄú×°ÖõÄGradleµÄ°æ±¾ºÅ¡£ÉúÑIJ¢Í˳ö±à¼­Æ÷£¬È»ºóÖ´ÐÐÒÔÏÂÏÂÁîʹÉèÖÃÉúЧ£º

sudo chmod +x /etc/profile.d/gradle.sh
source /etc/profile.d/gradle.sh

µÇ¼ºó¸´ÖÆ

°ì·¨ËÄ£º½¨ÉèÇø¿éÁ´ÏîÄ¿

ÔÚIntelliJ IDEAÖУ¬½¨ÉèÒ»¸öеÄÇø¿éÁ´ÏîÄ¿ºÜÊǼòÆÓ¡£·­¿ªIntelliJ IDEA£¬ÔÚ½Ó´ý½çÃæÑ¡Ôñ¡°Create New Project¡±»òÕßÔڲ˵¥À¸Ñ¡Ôñ¡°File¡±->¡°New Project¡±¡£

ÔÚ¡°New Project¡±¶Ô»°¿òÖУ¬Ñ¡Ôñ¡°Gradle¡±×÷ΪÏîÄ¿ÀàÐÍ£¬²¢µã»÷¡°Next¡±°´Å¥¡£½ÓÏÂÀ´£¬Ñ¡ÔñÄúÏ£Íû½¨ÉèÏîÄ¿µÄĿ¼£¬²¢ÊäÈëÏîÄ¿µÄÃû³Æ¡£µã»÷¡°Finish¡±°´Å¥À´½¨ÉèÏîÄ¿¡£

°ì·¨Î壺ÉèÖÃÇø¿éÁ´ÒÀÀµÏî

·­¿ªÏîÄ¿ºó£¬ÄúÐèÒªÉèÖÃÏîÄ¿µÄÒÀÀµÏî¡£±à¼­ÏîÄ¿ÖеÄbuild.gradleÎļþ£¬Ìí¼ÓÒÔÏÂÄÚÈÝ£º

repositories {
    mavenCentral()
}

dependencies {
    implementation group: 'org.web3j', name: 'core', version: '4.8.3'
    implementation group: 'org.ethereum', name: 'ethereumj-core', version: '1.9.0-RELEASE'
}

µÇ¼ºó¸´ÖÆ

ÉÏÊö´úÂëÖУ¬ÎÒÃÇÌí¼ÓÁËWeb3jºÍEthereumjµÄÒÀÀµÏî¡£Web3jÊÇÒ»¸öÓÃÓÚÓëÒÔÌ«·»Çø¿éÁ´¾ÙÐн»»¥µÄJava¿â£¬¶øEthereumjÊÇÒ»¸öJavaʵÏÖµÄÒÔÌ«·»¿Í»§¶Ë¡£

ÉúÑIJ¢¹Ø±Õbuild.gradleÎļþºó£¬IntelliJ IDEA»á×Ô¶¯ÏÂÔØËùÐèµÄÒÀÀµÏî¡£

°ì·¨Áù£º±àдÇø¿éÁ´´úÂë

ÏÖÔÚ£¬Äú¿ÉÒÔ×îÏȱàдÇø¿éÁ´Ïà¹ØµÄ´úÂëÁË¡£ÔÚsrc/main/javaĿ¼Ï½¨ÉèÒ»¸öеÄJavaÀ࣬²¢ÔÚ¸ÃÀàÖбàдÄúµÄÇø¿éÁ´´úÂë¡£

ÒÔÏÂÊÇÒ»¸ö¼òÆÓµÄʾÀý´úÂ룺

import org.web3j.crypto.Credentials;
import org.web3j.crypto.ECKeyPair;
import org.web3j.protocol.Web3j;
import org.web3j.protocol.http.HttpService;
import org.web3j.protocol.core.methods.response.EthBlockNumber;

public class BlockchainExample {
    public static void main(String[] args) {
        // ÅþÁ¬µ½ÒÔÌ«·»½Úµã
        Web3j web3j = Web3j.build(new HttpService("https://ropsten.infura.io/v3/your-infura-project-id"));

        // ½¨ÉèÒ»¸öеÄÃÜÔ¿¶ÔºÍƾ֤
        ECKeyPair keyPair = ECKeyPair.create("your-private-key");
        Credentials credentials = Credentials.create(keyPair);

        // »ñÈ¡×îеÄÇø¿éºÅ
        EthBlockNumber blockNumber;
        try {
            blockNumber = web3j.ethBlockNumber().send();
            System.out.println("Latest block number: " + blockNumber.getBlockNumber());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

µÇ¼ºó¸´ÖÆ

ÔÚÉÏÊöʾÀýÖУ¬ÎÒÃÇʹÓÃWeb3j¿âÅþÁ¬µ½ÒÔÌ«·»½Úµã£¬²¢½¨ÉèÁËÒ»¸öеÄÃÜÔ¿¶ÔºÍƾ֤¡£È»ºó£¬ÎÒÃÇ»ñÈ¡ÁË×îеÄÇø¿éºÅ²¢½«Æä´òÓ¡Êä³öµ½¿ØÖÆ̨¡£

°ì·¨ÆߣºÔËÐÐÇø¿éÁ´ÏîÄ¿

×îºóÒ»²½ÊÇÔËÐÐÇø¿éÁ´ÏîÄ¿¡£ÔÚIntelliJ IDEAÖУ¬µã»÷²Ëµ¥À¸Öеġ°Run¡±->¡°Run¡±°´Å¥£¬»òÕßʹÓÿì½Ý¼üShift+F10À´ÔËÐÐÄúµÄÇø¿éÁ´ÏîÄ¿¡£

ÔËÐÐÀֳɺó£¬Äú½«ÔÚ¿ØÖÆ̨´°¿ÚÖп´µ½ÓëÇø¿éÁ´½»»¥µÄЧ¹û¡£

×ܽ᣺

±¾ÎÄÏÈÈÝÁËÔÚlinuxϵͳÉÏʹÓÃintellij idea¾ÙÐÐÇø¿éÁ´¿ª·¢µÄÉèÖÃÒªÁ죬²¢¸½ÉÏÁËÏêϸµÄ´úÂëʾÀý¡£Í¨¹ýƾ֤ÒÔÉÏ°ì·¨¾ÙÐÐÉèÖã¬Äú¿ÉÒÔ¿ìËٴÆðÒ»¸öÇø¿éÁ´¿ª·¢ÇéÐΣ¬²¢¾ÙÐнøÒ»²½µÄ¿ª·¢ºÍÑо¿¡£

Ï£ÍûÕâƪÎÄÕ¶ÔÄúÓÐËù×ÊÖú£¬×£ÄúÇø¿éÁ´¿ª·¢Ë³Ë죡

ÒÔÉϾÍÊÇÔÚLinuxϵͳÉÏʹÓÃIntelliJ IDEA¾ÙÐÐÇø¿éÁ´¿ª·¢µÄÉèÖÃÒªÁìµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是博ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是博ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是博

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
sitemap¡¢ÍøÕ¾µØͼ