Monday, July 27, 2009

How do I merge multiple java files together instead of having them seperate?

I am working on Data Structures assignment. I have 6 java files in a folder. So how do I merge those 6 files together instead of having them in the folder seperately?

How do I merge multiple java files together instead of having them seperate?
If your goal is to have one big file - merge them - then you must create a .jar file. If you are using the Eclipse compiler, go to File --%26gt; Create Jar, and follow the process.





Or, if your goal is not to merge them, but to have them together, select all the files, right click any one of them, go to send to, and then go to Compressed (Zip) folder.





Good luck
Reply:there are two ways :


1)make a package, or


2)make a jar file


To merge multiple files, u can make a directry(say package in java)and save all these file in that particular package.It will also help u to import the files in other files by just importing the package.For putting the files in a package u have to just mention the name of package at the top of program/file.for example,package p1. Here 'package' is a keyword and 'p1' is a package name.and then save the file in the package. eg c:\java\bin\p1\filename.


Another way is to make a jar file and put the files in jar file. for example, jar cf JARF.jar *.class or


jar cf JARF.jar file1.class. Here 'jar' and 'cf' are the keywords and JARF.jar is the filename in which u want to merge the files, and *.class(all files with extension .class) and 'file1.class' are the files that u want to merge.this way also provides u file compression and security.

anther

No comments:

Post a Comment