Shared class in java.

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Jun 2008
Posts: 46
Reputation: zyaday is an unknown quantity at this point 
Solved Threads: 1
zyaday zyaday is offline Offline
Light Poster

Shared class in java.

 
0
  #1
Apr 29th, 2009
I have many projects in a software. Although some files and classes are shared within these projects, there are classes used by most of these projects. How do i creat classes that can be shaed among different projects . Is there anything in java that can function the same as 'modules' in vb.net?
Thanks a lot.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 1,681
Reputation: javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all 
Solved Threads: 227
Featured Poster
javaAddict's Avatar
javaAddict javaAddict is offline Offline
Posting Virtuoso

Re: Shared class in java.

 
0
  #2
Apr 29th, 2009
Create a seperate Project with some classes and then you can import these classes like you import any other class:

  1. import java.util.*

The only difference is that you will be importing your classes with their packages.
You can take the .class files (in their folder/package) or create a jar file with the classes. Then add that to the classpath of the project you want them to be used.
Check out my New Bike at my Public Profile at the "About Me" tab
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 46
Reputation: zyaday is an unknown quantity at this point 
Solved Threads: 1
zyaday zyaday is offline Offline
Light Poster

Re: Shared class in java.

 
0
  #3
Apr 29th, 2009
thanks lots i will try that...
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2,657
Reputation: adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of 
Solved Threads: 474
Moderator
adatapost's Avatar
adatapost adatapost is offline Offline
Posting Maven

Re: Shared class in java.

 
0
  #4
Apr 29th, 2009
Dear,

Create .jar of those classes you want to use them in different projects and append the entry of .jar file CLASSPATH environment variable.

PS:
You can place .jar files in \jdk1.6.0\jre\lib\ext . (shared folder of jvm - am I?, Mr. Ancient Dragon.).
Failure is not fatal, but failure to change might be. - John Wooden
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC