Win a copy of Emmy in the Key of Code this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

Creating jar files with eclipse ?

 
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1 - As a somewhat experienced beginner, will I "cripple" myself by using eclipse instead of command line ?

2 - I have two projects B and C. C uses classes in B. I want to convert C to a jar, using eclipse. I want to know the different ways in which I can do this.
I know we can do it by configuring build path of C to include B, ie dependency. How do we do it without the dependency ? How do we do it with import
statements and without them ? How do we do it using the import menu in eclipse ?

3 - How do we do each of the things in 2 with command line ?

Thanks.
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1:
Eclipse is an IDE. It highlights code syntax, it builds JARs, it connects to SVN, it has code completion, and it does hundreds of little other things. Using Eclipse will not cripple you, but can only help you.

2:
I've never done that before

3:
I've never done 2 before.
 
Bartender
Posts: 11445
18
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Andy Jack wrote:1 - As a somewhat experienced beginner, will I "cripple" myself by using eclipse instead of command line ?


Cirpple? No. Hamper. Yes
Using a command line will help you learn how important concepts like packages, path, classpath, difference between the two. IDEs like Eclipse will abstract all this from you. I would suggest start off with command line, and then graduating to IDEs.

Andy Jack wrote:
2 - I have two projects B and C. C uses classes in B. I want to convert C to a jar, using eclipse. I want to know the different ways in which I can do this.
I know we can do it by configuring build path of C to include B, ie dependency. How do we do it without the dependency ? How do we do it with import
statements and without them ? How do we do it using the import menu in eclipse ?


If you want to use any external class/package in your code, you need to ensure the classes/jar is available on the class path. Jar is nothing but a "zipped" version which can contain one single class or typically a package hierarchy. More on classpath here https://coderanch.com/how-to/java/HowToSetTheClasspath

Andy Jack wrote:
3 - How do we do each of the things in 2 with command line ?


More about jar files here http://docs.oracle.com/javase/1.4.2/docs/tooldocs/windows/jar.html
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Andy Jack wrote:1 - As a somewhat experienced beginner, will I "cripple" myself by using eclipse instead of command line ?


It won't cripple you. just make sure you know how Java works and know about classpaths (because it will become important).

2 - I have two projects B and C. C uses classes in B. I want to convert C to a jar, using eclipse. I want to know the different ways in which I can do this.


You can add project B to project C's classpath using the Project > Properties dialog > Java Build Path on the Projects tab. Or you can export project B as a JAR and add the JAR to project C's build path (on the Libraries tab). Either way you want to go to the Order and Export tab and add project B's Project/JAR.

You can export a project to a JAR either 'manually' by right-clicking on the project, choosing Export... > Java > JAR (or Execuatble JAR). When prompted for the resources to export, make sure you include the project B Project/JAR as well.

You can add an Ant Build script to automate building the JAR using Project > Properties > Builders and adding a new Ant Builder (there will be significant configuration required).

I know we can do it by configuring build path of C to include B, ie dependency. How do we do it without the dependency ?


Copy the .java files into project C, or stop using two separate projects.

How do we do it with import statements and without them ?


Don't try avoiding import statements. The only way to avoid this is if you put everything in one package, which is bad practice.

How do we do it using the import menu in eclipse ?


My eclipse doesn't have an import menu.
 
Andy Jack
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Russell Slighton wrote:1:
Eclipse is an IDE. It highlights code syntax, it builds JARs, it connects to SVN, it has code completion, and it does hundreds of little other things. Using Eclipse will not cripple you, but can only help you.

2:
I've never done that before

3:
I've never done 2 before.



Bliss !
 
Why am I so drawn to cherry pie? I can't seem to stop. Save me tiny ad!
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!