Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » start a new Java project with an existing package??
start a new Java project with an existing package?? [message #718383] Wed, 24 August 2011 07:37 Go to next message
javawriter is currently offline javawriterFriend
Messages: 1
Registered: August 2011
Junior Member
I have Java classes already. Each has a package statement. They compile just fine outside of Eclipse.

I now wish to create a new project in Eclipse and not alter the package statements in these Java classes. How do I do that?

Here are the things I want Eclipse to accept as-is:

Source file: C:\jed\prog\utils\XYZ.java
package prog.utils;
class XYZ {}

CLASSPATH includes C:\jed (the root of the package--yes, this compiles just fine outside of Eclipse)

The Eclipse issue I'm facing: Eclipse flags my package statement as an error. It gives me two choices: move my files into a new nested directory named after my package (nope, wrong solution) or delete the package statement (nope, wrong solution).

I want the new project to use the *.java files in C:\jed\prog\utils ... files with "package prog.utils".

These current definitions do NOT work:
.classpath (currently in the "utils" folder):
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
	<classpathentry kind="src" path=""/>
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
	<classpathentry kind="lib" path="C:/jed"/>
	<classpathentry kind="output" path="bin"/>
</classpath>


.project (currently in the "utils" folder):
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
	<name>Utils</name>
	<comment></comment>
	<projects>
	</projects>
	<buildSpec>
		<buildCommand>
			<name>org.eclipse.jdt.core.javabuilder</name>
			<arguments>
			</arguments>
		</buildCommand>
	</buildSpec>
	<natures>
		<nature>org.eclipse.jdt.core.javanature</nature>
	</natures>
</projectDescription>


Ideas?

Thanks!
Re: start a new Java project with an existing package?? [message #718524 is a reply to message #718383] Wed, 24 August 2011 15:29 Go to previous message
David Wegener is currently offline David WegenerFriend
Messages: 1445
Registered: July 2009
Senior Member
You need to set the project location to C:\jed instead of C:\jed\prog\utils. You then need to make the project root be the Source directory. This will place the prog.utils package in the correct location relative to the projects source root.
Previous Topic:Best way to add warnings
Next Topic:How I get Eclipse to see j3d alongside jdk1.7.0 ?
Goto Forum:
  


Current Time: Thu Apr 25 00:30:04 GMT 2024

Powered by FUDForum. Page generated in 0.03168 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top