Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jul 3rd, 2009, 10:26 AM   #1
navi2000
Newbie
 
Join Date: Jul 2009
Posts: 3
Rep Power: 0 navi2000 is on a distinguished road
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.
navi2000 is offline   Reply With Quote
Old Jul 3rd, 2009, 6:48 PM   #2
amragman
Genemesis
 
amragman's Avatar
 
Join Date: Jul 2009
Posts: 44
Rep Power: 0 amragman is on a distinguished road
Re: Include library

Quote:
Originally Posted by navi2000 View Post
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.
In Java we use import keyword to include library files.
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
amragman is offline   Reply With Quote
Old Jul 3rd, 2009, 7:50 PM   #3
navi2000
Newbie
 
Join Date: Jul 2009
Posts: 3
Rep Power: 0 navi2000 is on a distinguished road
Re: Include library

Quote:
Originally Posted by amragman View Post
In Java we use import keyword to include library files.
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.
I'm not talking about to use a Java source file from another source file. I'm talking about include a folder with several Java files to the project that will be compiled at the same time the project files will.

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.
navi2000 is offline   Reply With Quote
Old Jul 3rd, 2009, 7:55 PM   #4
amragman
Genemesis
 
amragman's Avatar
 
Join Date: Jul 2009
Posts: 44
Rep Power: 0 amragman is on a distinguished road
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
amragman is offline   Reply With Quote
Old Jul 3rd, 2009, 8:00 PM   #5
navi2000
Newbie
 
Join Date: Jul 2009
Posts: 3
Rep Power: 0 navi2000 is on a distinguished road
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).
navi2000 is offline   Reply With Quote
Old Jul 4th, 2009, 2:34 AM   #6
amragman
Genemesis
 
amragman's Avatar
 
Join Date: Jul 2009
Posts: 44
Rep Power: 0 amragman is on a distinguished road
Re: Include library

You can always copy the folder to working project..
__________________
Genemesis
amragman is offline   Reply With Quote
Old Jul 8th, 2009, 9:10 AM   #7
Alexandra N
Newbie
 
Join Date: Jul 2009
Posts: 1
Rep Power: 0 Alexandra N is on a distinguished road
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)
Alexandra N is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 12:00 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC