We prove it by contrapositive. (I assume you know that compact implies closed in general; if you don't want to invoke this fact, then see ahead).
For each $j\in I$, let $\mathscr{O}_j = \mathbb{R}-A_j$. Since $A_j$ is closed, $\mathscr{O}_j$ is open.
If $\bigcap\limits_{i\in I}A_i=\emptyset$, then $\mathbb{R} = \mathbb{R}-\bigcap_{j\in I}A_j = \bigcup_{j\in I}(\mathbb{R}-A_j)= \bigcup_{j\in I}\mathscr{O}_j.$
In particular, for any $i\in I$, $A_i\subseteq \bigcup_{j\in I}\mathscr{O}_j$. Fix $i_0\in I$. Since $A_{i_0}$ is compact, this open cover has a finite subcover, $\mathscr{O}_{j_1}\cup\cdots\cup\mathscr{O}_{j_n}$. So $A_{i_0}\subseteq \mathscr{O}_{j_1}\cup\cdots\cup\mathscr{O}_{j_n}.$ That means that $\emptyset = A_{i_0}\cap\left(\mathbb{R}-\bigcup_{k=1}^n\mathscr{O}_{j_k}\right) = A_{i_0}\cap\left(\mathbb{R}-\bigcup_{k=1}^n(\mathbb{R}-A_{j_k})\right) = A_{i_0}\cap\left(\bigcap_{k=1}^n A_{j_k}\right).$ Thus, there is a finite subcollection that has empty intersection.
We have shown that if the entire family has empty intersection, then there is a finite subcollection that has empty intersection. By contrapositive, this gives the desired result.
Added. If you want to show that compact implies closed (at least in $\mathbb{R}$; in fact, it is true in any Hausdorff space) directly using the definition, let $C$ be compact in $\mathbb{R}$, and let $x\notin C$. Then for every $c\in C$ there is an open set $\mathscr{O}_c$ that contains $c$ and an open set $\mathscr{U}_c$ that contains $x$ with $\mathscr{U}_c\cap \mathscr{O}_c=\emptyset$. Since $\cup \mathscr{O}_c$ contains $C$, which is compact, there is a finite subcover $C\subseteq \mathscr{O}_{c_1}\cup\cdots\cup \mathscr{O}_{c_n}$. Let $\mathscr{U}=\mathscr{U}_{c_1}\cap\cdots \cap \mathscr{U}_{c_n}$. Then $\mathscr{U}$ is an open set that constains $x$, and $\mathscr{U}\cap C\subseteq \mathscr{U}\cap(\mathscr{O}_{c_1}\cup\cdots \cup \mathscr{O}_{c_n}) = \emptyset,$ so $x\notin \overline{C}$. Thus, $\overline{C}\subseteq C$, which gives $C=\overline{C}$, so $C$ is indeed closed.