Peter Chan
asked on
Way to create the library
Hi,
Is there any demonstration/shared way, to create Java libraries, using Eclipse?
if I create one Java library, is there one place that I can register/put it, like, to one .com or .org site, to further share/use it?
When I'm to create one Java library, should I choose "Plug in Project", within Eclipse?
Is there any demonstration/shared way, to create Java libraries, using Eclipse?
if I create one Java library, is there one place that I can register/put it, like, to one .com or .org site, to further share/use it?
When I'm to create one Java library, should I choose "Plug in Project", within Eclipse?
ASKER
Thanks a lot.
Does it mean Jar file is executable, which can also be used as a library?
Is there any tutorials to create library/jar files?
Does it mean Jar file is executable, which can also be used as a library?
Is there any tutorials to create library/jar files?
ASKER
I create one project
https://dl.dropboxusercontent.com/u/40211031/JLib.zip
using Eclipse. How to find out jar file from it?
https://dl.dropboxusercontent.com/u/40211031/JLib.zip
using Eclipse. How to find out jar file from it?
Please check this link for more details....
http://www.mkyong.com/ant/ant-how-to-create-a-jar-file-with-external-libraries/
http://www.vogella.com/tutorials/JavaLibraries/article.html#jarfiles_executable
http://viralpatel.net/blogs/create-jar-file-in-java-eclipse/
https://www.cs.utexas.edu/~scottm/cs307/handouts/Eclipse%20Help/jarInEclipse.htm
hope this will help you to solve the problem.
http://www.mkyong.com/ant/ant-how-to-create-a-jar-file-with-external-libraries/
http://www.vogella.com/tutorials/JavaLibraries/article.html#jarfiles_executable
http://viralpatel.net/blogs/create-jar-file-in-java-eclipse/
https://www.cs.utexas.edu/~scottm/cs307/handouts/Eclipse%20Help/jarInEclipse.htm
hope this will help you to solve the problem.
ASKER
How to get the Jar file to the recent project? Thanks
Right click on your project.
Choose Export -> Java -> JAR file
Choose included files and name output jar, click "Next"
Check "Save the description of this JAR in the workspace" and chose a name for the new jardesc file.
Choose Export -> Java -> JAR file
Choose included files and name output jar, click "Next"
Check "Save the description of this JAR in the workspace" and chose a name for the new jardesc file.
ASKER
Many thanks. I try to run against the Jar file like
C:\Eclipse\JLib>java -jar JLib.jar
no main manifest attribute, in JLib.jar
how to correct the message prompted in above?
If you dont have a manifest in your jar invoking java -jar will not work.
Use this command if you dont have a manifest:
java -cp foo.jar full.package.name.ClassNam e
look at this conversations:
http://stackoverflow.com/questions/9689793/cant-execute-jar-file-no-main-manifest-attribute
http://stackoverflow.com/questions/1238145/how-to-run-a-jar-file
Use this command if you dont have a manifest:
java -cp foo.jar full.package.name.ClassNam
look at this conversations:
http://stackoverflow.com/questions/9689793/cant-execute-jar-file-no-main-manifest-attribute
http://stackoverflow.com/questions/1238145/how-to-run-a-jar-file
C:\Eclipse\JLib>java -jar JLib.jar
means it's a stand-alone app. Is it?
ASKER
Thanks all.
CEHI,
yes
CEHI,
yes
Then you haven't named the main class correctly in the manifest (done in the IDE if using one). Use the fully-qualified package name
ASKER
Thanks. can I have the details to create manifest, to the project, using Eclipse?
follow this link to create manifest using eclipse........
http://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Ftasks%2Ftasks-35.htm
http://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Ftasks%2Ftasks-35.htm
ASKER
I also get it from Help of Eclipse. Can you show me in details to do this? thanks
as per your question you can also use plugin........see below link
http://www.acnenomor.com/6064241p2/eclipse-create-runnable-jar-with-manifest-possible
http://www.acnenomor.com/6064241p2/eclipse-create-runnable-jar-with-manifest-possible
ASKER
Can I work with manifest, without the plug-in?
in Eclipse you can but.............but it is not runnable
If you're using Eclipse, you export as a jar to accomplish your goal:
http://help.eclipse.org/luna/topic/org.eclipse.jdt.doc.user/reference/ref-export-jar.htm
Make sure the application's entry point is set in the wizard. Then it will be runnable
http://help.eclipse.org/luna/topic/org.eclipse.jdt.doc.user/reference/ref-export-jar.htm
Make sure the application's entry point is set in the wizard. Then it will be runnable
ASKER
Thanks a lot.
How to to resolve this
How to to resolve this
Description Resource Path Location Type
CalCl cannot be resolved to a type CalCl3.java /JLib3/src/CalCl3 line 3 Java Problem
using these codes?package CalCl3;
public class CalCl3 implements CalCl {
}
ASKER
While CalCl does exists within the another Java project, that is
https://dl.dropboxusercontent.com/u/40211031/JLib2.zip
https://dl.dropboxusercontent.com/u/40211031/JLib2.zip
ASKER
I get the same problem, even if I adjust the codes to
package CalCl3;
import JLib2.Calcl;
public class CalCl3 implements CalCl {
}
I'm not really much of an Eclipse user, but does it run properly in the IDE?
ASKER
I'm to compile it and then have got the issue. thanks
ASKER
Can you try to open it, if available? thanks.
There's no main method in your last source - so it will never 'run' as such, but it will compile
ASKER
Sorry, I am not able to compile these
why?
package CalCl3;
import JLib2.Calcl;
public class CalCl3 implements CalCl {
}
why?
It's probably something to do with the way you have the projects linked. That import statement is also probably wrong
You didn't actually include Calc3 in the source you linked to
You didn't actually include Calc3 in the source you linked to
ASKER
What to adjust to the codes above?
You need to name the packages correctly (I don't know what the names should be) and make sure the projects are linked thru the IDE
ASKER
what to adjust to make it work?
ASKER
what do you mean by "linked thru the IDE"?
I mean that IDEs give you the facility of sharing code amongst projects but they have to be told to do that. In your case, it sounds as if it could be better to create a library that's reusable rather than have it in a shared project.
ASKER
But I did attach jar file to JLib3. Can you please tell me what is wrong inside it below?
https://dl.dropboxusercontent.com/u/40211031/JLib3.zip
https://dl.dropboxusercontent.com/u/40211031/JLib3.zip
That doesn't contain source for interface CalCl
ASKER
No, JLib2.jar is under Referenced Libraries of JLib3 project.
ASKER
See the attached
t965.png
t965.png
You misunderstand - i'm saying it's not in that download - nor is there any jar IN it
ASKER
Do you see the attached screenshot?
Well that looks good as far as the IDE is concerned, but of course doesn't help with that download. Find that referenced jar and run the following command on it, having changed to the directory which contains it. Then post the output please
jar tf JLib2.jar
ASKER
Here are what I get
C:\Eclipse\JLib2>jar tf JLib2.jar
'jar' is not recognized as an internal or external command,
operable program or batch file.
C:\Eclipse\JLib2>java
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
....
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Please read this points:
->Just use the source
In the properties of the project which has the dependencies you can add another source-folder:
Properties > Java Build Path > Tab: Source > Add Folder...
In the Project Tab you can "add" the whole project to the other project, too. There are many ways to achieve your goal.
->Create and add the library to the Build-Path
Adding an existing Jar (your own library):
If it is in the workspace:
Properties > Java Build Path > Tab: Libraries > Add JARs...
If it is somewhere on the drive:
Properties > Java Build Path > Tab: Libraries > Add External JARs...
->Exporting a source folder as a library
text Menu of Source Folder > Export > Jar File
There are two types: Executable Jars and "normal" Jars. You don't need an executable Jar.