aspose file tools*
The moose likes IDEs, Version Control and other tools and the fly likes eclipse ~~compile java file question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "eclipse ~~compile java file question" Watch "eclipse ~~compile java file question" New topic
Author

eclipse ~~compile java file question

Alvin chew
Ranch Hand

Joined: Jan 08, 2004
Posts: 834
hi, new to eclipse, i would like to compile a java file which is actually javabeans with no main function, how to i compile it ? thank you !
Santosh Maskar
Ranch Hand

Joined: Jul 02, 2003
Posts: 226
Originally posted by Alvin chew:
hi, new to eclipse, i would like to compile a java file which is actually javabeans with no main function, how to i compile it ? thank you !


Hi
When you create a new file and save it , this file automatically compile , there is no need to compile separatly.
Alvin chew
Ranch Hand

Joined: Jan 08, 2004
Posts: 834
oh...is it ? meaning what i need is just to save it ? it will auto generate class ?
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Alvin,

Notice that with Eclipse 3, in the "Project" menu, you can select or deselect "Build Automatically." If it's deselected, then in the same menu you can select "Build All."


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Alvin chew
Ranch Hand

Joined: Jan 08, 2004
Posts: 834
hi, Dirk, even i try on build all , but it doesn't compile me the class file.

what i actually doing is create java file for the folder under WEB-INF, say "testing", i want to create some java file inside testing which under web-inf\classes\testing ..

so, i create a new "project" and put the name for project, then i select "create project at external location", then i browse to "web-inf\classes\testing", it does show me the existing java file and class file in package view tree, but when i create a new java file, i can't create class and also cannot compile, i use "build all" function as you mentioned, but it doesn't work..am i doing the right way to mount folder ? thank you !
[ September 06, 2004: Message edited by: Alvin chew ]
Santosh Maskar
Ranch Hand

Joined: Jul 02, 2003
Posts: 226
you need to write the ant script (build.xml) for doing same

refere http://ant.apache.org/
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Santosh Maskar:
you need to write the ant script (build.xml) for doing same

refere http://ant.apache.org/


No, you don't.

What you *need* to do is checking your projects Build Path (in the projects preferences), especially the source folder and the output folder.

Eclipses online help might also help you in this respect...


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Santosh Maskar
Ranch Hand

Joined: Jul 02, 2003
Posts: 226
Originally posted by Ilja Preuss:


No, you don't.

What you *need* to do is checking your projects Build Path (in the projects preferences), especially the source folder and the output folder.

Eclipses online help might also help you in this respect...



Hi
Thats right but onluy classes are able to copy on target folder
you need to write the custome ant script so that only requried resources will be put into the target path

if my application uses third party API (JAr )
then for every thired party i need to include this jar in my project that is not good to wirte the program just i need to refer the path of the jar and using ant script we can do this , if we use the eclipse then it copys all the files to the target folder, if my application have some document then it also copy to the target folder.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Santosh Maskar:
if my application uses third party API (JAr )
then for every thired party i need to include this jar in my project


No, you just need to reference it in the Build Path.

if we use the eclipse then it copys all the files to the target folder


No, only non-java files in the source directory are copied to the target folder. If you don't use the project folder as the source directory, you can easily have, say, a lib folder inside the project that holds your thirdparty jars.
Fred Grott
Ranch Hand

Joined: Oct 05, 2002
Posts: 346
ahem both of you have soem points and some points wrong..

he will at soem point need to compose an ant script, althoguh not now..


MobileBytes blog - Sharing Technology - My Programming Knols
Santosh Maskar
Ranch Hand

Joined: Jul 02, 2003
Posts: 226
Thats true, but there is no need to copy the unwanted files in target folder

In eclipse we can set the default output folder , in case of java project or tomcat project it create the same directory structure for output files , but i need to copy only project related files , if my application have soome test program then i dont want to opy the test program in to the output folder ,

still we can use the build in functinality provided by the eclipse and also write the ant script for same.
Arundhathi Menon
Ranch Hand

Joined: Jan 14, 2004
Posts: 113
Hi!
I guess all u need to do is specify ur source files ( u can import it from an existing soiurce directory if u want)
U need to change the defualt class path to the class folder that u have created ...after specifying the required jars that need to be added to ur path u just need to activate the Build Automatically option of the project main menu option...
Every time u create a new file under the source direftory ur class path will automatically contain the corresponding class file

All the best

regards
Menon


SCJP , SCWCD , SCBCD , SCDJWS
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Santosh Maskar:
i need to copy only project related files , if my application have soome test program then i dont want to opy the test program in to the output folder


Use a different source folder for your test program and configure a different output folder for it.

Or put the test program into a different project. That's more work to do, but makes sure that your production classes don't accidentally depend on some test classes (which then could lead to some nasty ClassNotFoundExceptions at runtime).
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Fred Grott:
ahem both of you have soem points and some points wrong..

he will at soem point need to compose an ant script, althoguh not now..


Possibly. He doesn't need Ant to compile his project, though, and that was my whole point.
 
 
subject: eclipse ~~compile java file question