![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Jul 2009
Posts: 3
Rep Power: 0
![]() |
Include library
Hi, I'm new to Java and I would like to know if there is a C-style include functionality in Java.
In C/C++ you could tell compiler that must include all files in a given folder. These files will be compiled together with your project. In Java, I'm using Netbeans and this functionality seems not to be present. You can add a folder (project properties/libraries), but the files must be pre-compiled (class files, not Java files). My intention is to have a separate set of java files that many projects can include at convenience, so if I change anything in these set of files and recompile a project, it will be reflected automatically. |
|
|
|
|
|
#2 | |
|
Genemesis
Join Date: Jul 2009
Posts: 44
Rep Power: 0
![]() |
Re: Include library
Quote:
Syntax is import java.io.*; If you want to use your own files as library files first make sure they are compiled then put them in appropriate folder and use it like this import foldername.filename; For more please use Google.
__________________
Genemesis |
|
|
|
|
|
|
#3 | |
|
Newbie
Join Date: Jul 2009
Posts: 3
Rep Power: 0
![]() |
Re: Include library
Quote:
For instance, when I create a new Java project, NB creates a structure with a folder "src" where my Java files will be put. I want to include an additional folder outside my project (i.e. ../common/src). In C it's easy changing a project setting and I would like to know if it is as easy or it's not possible to do it. |
|
|
|
|
|
|
#4 |
|
Genemesis
Join Date: Jul 2009
Posts: 44
Rep Power: 0
![]() |
Re: Include library
Simply use import foldername.*;
Here folder should be located locally just like in C or C++ I said compiled files because sometimes it becomes messy to correct errors when they come from many files.
__________________
Genemesis |
|
|
|
|
|
#5 |
|
Newbie
Join Date: Jul 2009
Posts: 3
Rep Power: 0
![]() |
Re: Include library
import foldername.* cannot work because the folder that contains the Java files I want to include is outside my project structure (really it is part of another project).
|
|
|
|
|
|
#6 |
|
Genemesis
Join Date: Jul 2009
Posts: 44
Rep Power: 0
![]() |
Re: Include library
You can always copy the folder to working project..
__________________
Genemesis |
|
|
|
|
|
#7 |
|
Newbie
Join Date: Jul 2009
Posts: 1
Rep Power: 0
![]() |
Re: Include library
I'm not sure if this is what you're looking for, but I'd recommend you to read a little about JNI.
"The JavaTM Native Interface (JNI) is a powerful feature of the Java platform. Applications that use the JNI can incorporate native code written in programming languages such as C and C++, as well as code written in the Java programming language"(from The Java Native Interface Programmer's Guide and Specification) |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| error cant include file | squills | C++ | 3 | May 8th, 2009 7:16 PM |
| How to build a self-dependent library file | cu2nite | C++ | 1 | Sep 2nd, 2008 12:24 AM |
| Graphics Library? | grimpirate | PHP | 0 | Aug 23rd, 2008 4:34 PM |
| Discussion: How to implement the 'glue' between app and a library? | Eoin | C++ | 10 | Sep 28th, 2006 9:14 AM |
| Dev-C++ - #include .cpp/.h files | Cache | C++ | 5 | Nov 25th, 2005 12:34 PM |