There is a folder and in it are already compiled classes. How to call methods from them? Threw in the project directory, and wrote
import javax.help; As a result, Error: (15, 18) java: package javax.help does not exist.
There is a folder and in it are already compiled classes. How to call methods from them? Threw in the project directory, and wrote
import javax.help; As a result, Error: (15, 18) java: package javax.help does not exist.
Console example
Directory structure:
C:\dev\ TestImp.class c:\dev\mypack\ Test.class Test class code:
package mypack; public class Test { public Test() { System.out.println("I live!"); } } TestImp class code:
import mypack.Test; public class TestImp { public static void main(String[] args) { Test t = new Test(); } } In the console, go to the c: \ dev \ directory and execute:
java TestImp The console displays:
I live! UPD:
As for Intellj Idea - you need to pack your class files in the jar command
jar cf test.jar Test1.class After that, import the jar into the project as follows:
Структура проекта (CTRL + SHIFT + ALT + S on Windows/Linux, ⌘ + ; on Mac OS X) Modules на левой панели. Вкладка Dependencies '+' → JARs or directories UPD2:
Intellij IDEA allows you to add not only JARs, but also directories with classes. It is done completely the same as written above, only the directory with classes is selected. After selecting, a dialog opens in which you can exclude any subdirectories of the selected directory.
Source: https://ru.stackoverflow.com/questions/570815/
All Articles