Andriod and Java Develop Study Notes
How to Add JNI so Dependent
1.Copy the the jni so dependent to the libs folder.
2.Go to the “app” node, touch right mouse button, follow the click sequence you will finish the so dependent Add.
New=>Folder=>JNI Folder
the you will see such code segment was add in “build.gradle”
sourceSets {
main {
jni.srcDirs = ['libs', 'src/main/jni', 'src/main/jni/']
}
}
Chane the jni.srcDirs to your so location.
How to Change Android Launch Activity
Android project default launch activity is MainActivity, if we wanto change to other Customer Activity we can do like this:
Move "intent-filter segment " below your customer activity.
<activity android:name=".CUIDemo">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity">
</activity>
Install and Config MySql Service on Windows
- Get the MySql Binary Packge
https://dev.mysql.com/downloads/mysql/
Here my download version is mysql-5.7.24-winx64.zip - Unzip you mysql zip package into ProgramFile folder and Set Envirment Variable.
Set MYSQL_HOME=C:\Program Files\mysql-5.7.28-winx64 .
Add %MYSQL_HOME%/bin int to PATH. - Create a Config file in your MYSQL_HOME directory,named my.ini, like this;
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
[mysqld]
#设置3306端口
port = 3306
# 设置mysql的安装目录
basedir=C:\Program Files\mysql-5.7.28-winx64
# 设置mysql数据库的数据的存放目录
datadir=D:\data
# 允许最大连接数
max_connections=200
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
- Config Mysql
Open the Command line tools as administrator and input the config command as bellow, you will got a temp root password.
C:\Program Files\mysql-5.7.28-winx64\bin>mysqld --initialize --user=mysql --console --explicit_defaults_for_timestamp
2019-11-29T03:28:08.810091Z 0 [Warning] InnoDB: New log files created, LSN=45790
2019-11-29T03:28:08.845207Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2019-11-29T03:28:08.914930Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 439f23bc-1258-11ea-b246-54ee75fb1a80.
2019-11-29T03:28:08.918136Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2019-11-29T03:28:10.302927Z 0 [Warning] CA certificate ca.pem is self signed.
2019-11-29T03:28:11.332799Z 1 [Note] A temporary password is generated for root@localhost: ?,MSH<faM2Y<
- Install Mysql
C:\Program Files\mysql-5.7.28-winx64\bin>mysqld -install
Service successfully installed.
- Login Mysql
C:\Program Files\mysql-5.7.28-winx64\bin>mysql -u root -p
Enter password: ************
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.28
- Change Passward for Root
mysql> set password for root@localhost=password('123');
Query OK, 0 rows affected, 1 warning (0.00 sec)
10.Unstall Mysql
net stop mysql
mysqld-nt -install
mysqld-nt -remove
sc delete mysql
Eclipse Config Spring Boot Support
Create Project Use STS Plugin
- Install STS Plugin
Open Help->Eclipse Marketplace->Find “sts”, then you will see the STS plugin info. installed it and re-start eclipse. - Create a Spring Boot Project
Click File->New->Project->Spring Boot->Spring Starter Project->Next->Finish Then you will got a Spring boot Project. - Start the Project
Click The Project in the sln view, Run As ->Spring boot app, then your Project will be run.
Create Project Use Maven Plugin
Config Tomcat for Windows
1.Get the binary install package
https://tomcat.apache.org/
I got the version is “apache-tomcat-9.0.29-windows-x64.zip”
2.Install JDK
Get the binary source for Oracle official website, unzip to your install location, then configured the environment variable such as JAVA_HOME, then run Java - version to check if it work fine. mine environment configured like this:
C:\Users\heyx1>java -version
java version "1.8.0_181"
Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)
3.Tomcat Configured
- Add CATALINA_BASE System Environment Variable
Set CATALINA_BASE=C:\Program Files\apache-tomcat-9.0.29-windows-x64\apache-tomcat-9.0.29\ - Add CATALINA_HOME System Environment Variable
Set CATALINA_HOME=C:\Program Files\apache-tomcat-9.0.29-windows-x64\apache-tomcat-9.0.29\ - Add Classpath System Environment Variable
Set Classpath =.;%JAVA_HOME%\lib;TOMCAT_HOME%\lib - Add JRE_HOME System Environment Variable
JRE_HOME=C:\Program Files\Java\jdk1.8.0_181\jre or %JAVA_HOME%\jre\bin - Update Path Tomcat and java Path:
;%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin;%CATALINA_HOME%\bin;%CATALINA_HOME%\lib - Run Tomcat Server:
Enter TOMCAT_HOME\bin directory, run startup.bat and service.bat install as administrator.
C:\Program Files\apache-tomcat-9.0.29-windows-x64\apache-tomcat-9.0.29\bin>startup.bat
Using CATALINA_BASE: "C:\Program Files\apache-tomcat-9.0.29-windows-x64\apache-tomcat-9.0.29"
Using CATALINA_HOME: "C:\Program Files\apache-tomcat-9.0.29-windows-x64\apache-tomcat-9.0.29"
Using CATALINA_TMPDIR: "C:\Program Files\apache-tomcat-9.0.29-windows-x64\apache-tomcat-9.0.29\temp"
Using JRE_HOME: "C:\Program Files\Java\jdk1.8.0_181\jre"
Using CLASSPATH: "C:\Program Files\apache-tomcat-9.0.29-windows-x64\apache-tomcat-9.0.29\bin\bootstrap.jar;C:\Program Files\apache-tomcat-9.0.29-windows-x64\apache-tomcat-9.0.29\bin\tomcat-juli.jar"
C:\Program Files\apache-tomcat-9.0.29-windows-x64\apache-tomcat-9.0.29\bin>service.bat install
Installing the service 'Tomcat9' ...
Using CATALINA_HOME: "C:\Program Files\apache-tomcat-9.0.29-windows-x64\apache-tomcat-9.0.29"
Using CATALINA_BASE: "C:\Program Files\apache-tomcat-9.0.29-windows-x64\apache-tomcat-9.0.29"
Using JAVA_HOME: "C:\Program Files\Java\jdk1.8.0_181"
Using JRE_HOME: "C:\Program Files\Java\jdk1.8.0_181\jre"
Using JVM: "C:\Program Files\Java\jdk1.8.0_181\jre\bin\server\jvm.dll"
The service 'Tomcat9' has been installed.