NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

How do i add a java class to an existing project??

 
Post new topic   Reply to topic    NetBeans Forums -> Java EE Users
View previous topic :: View next topic  
Author Message
chaoscreater



Joined: 06 Aug 2010
Posts: 5

PostPosted: Fri Aug 06, 2010 11:40 pm    Post subject: How do i add a java class to an existing project?? Reply with quote

Hi guys, i'm new here. First of all, it's my very first time using Netbeans, i'm currently an UNI student and not very familiar with JAVA or any of the other tools yet, so please guide me through.

I was previously using Notepad++ but recently have heard about Netbeans, that it uses a really good GUI interface where i can use it as a WYSIWYG to build my JPanel, so i installed it yesterday and tried to do a few things and encountered some problems.

The first problem is, it seems i can't compile an existing .java file i created. I can open it and view it fine, but i can't compile or run it at all.

So then I referred to the tutorial and apparently I have to create a new project first. So i did, and the project came with a demo class, and i was able to compile and run it fine.

So this brings up my 2nd problem. After creating a project, I thought ok, maybe i just need to add my existing .java files/classes to the project and that'll work, but i've been trying to figure this part out for the past 40 mins or so and read a lot of documentation and guides on Netbeans and couldn't find out how.

Most of the guides i found were to add the .JAR files to the Libraries, which is found by going to the project file and choose Properties. But my files are in .java so not sure what to do here.


So basically, is there a way to simply compile and run the .java file in Netbeans without opening a project?? And lastly, how do i add a .java file to an existing project?


Please help me out, thanks.
Back to top
chaoscreater



Joined: 06 Aug 2010
Posts: 5

PostPosted: Fri Aug 06, 2010 11:42 pm    Post subject: Reply with quote

oops sorry my internet had a problem and posted 2 of the same topics. Please delete this one.
Back to top
jyeary



Joined: 21 Oct 2008
Posts: 605
Location: Simpsonville, SC

PostPosted: Mon Aug 09, 2010 4:39 pm    Post subject: Re: How do i add a java class to an existing project?? Reply with quote

No/Yes.

You can't just open a file and compile it from NB.

Copy the files to the project, right click the project, open the properties, go go run, and select your program

Please direct beginner questions to the correct forum. This forum is for web and enterprise development.

Sent from my iPhone

On Aug 6, 2010, at 19:41, "chaoscreater" <address-removed> wrote:

Quote:
Hi guys, i'm new here. First of all, it's my very first time using Netbeans, i'm currently an UNI student and not very familiar with JAVA or any of the other tools yet, so please guide me through.

I was previously using Notepad++ but recently have heard about Netbeans, that it uses a really good GUI interface where i can use it as a WYSIWYG to build my JPanel, so i installed it yesterday and tried to do a few things and encountered some problems.

The first problem is, it seems i can't compile an existing .java file i created. I can open it and view it fine, but i can't compile or run it at all.

So then I referred to the tutorial and apparently I have to create a new project first. So i did, and the project came with a demo class, and i was able to compile and run it fine.

So this brings up my 2nd problem. After creating a project, I thought ok, maybe i just need to add my existing .java files/classes to the project and that'll work, but i've been trying to figure this part out for the past 40 mins or so and read a lot of documentation and guides on Netbeans and couldn't find out how.

Most of the guides i found were to add the .JAR files to the Libraries, which is found by going to the project file and choose Properties. But my files are in .java so not sure what to do here.


So basically, is there a way to simply compile and run the .java file in Netbeans without opening a project?? And lastly, how do i add a .java file to an existing project?


Please help me out, thanks.



Back to top
pepelara



Joined: 29 Nov 2008
Posts: 115

PostPosted: Mon Aug 09, 2010 4:43 pm    Post subject: Re: How do i add a java class to an existing project?? Reply with quote

Well, you can copy your package in the source folder of your NB project.

I guess you have your classes inside a folder/subfolder/... Copy from the
root folder
in the src/java/ folder of the NB project (you will see it for the other
packges).
The IDE will open this package into your project.

Regards,
Jose

--------------------------------------------------
From: "chaoscreater" <address-removed>
Sent: Saturday, August 07, 2010 1:41 AM
To: <address-removed>
Subject: [nbj2ee] How do i add a java class to an existing project??

Quote:
Hi guys, i'm new here. First of all, it's my very first time using
Netbeans, i'm currently an UNI student and not very familiar with JAVA or
any of the other tools yet, so please guide me through.

I was previously using Notepad++ but recently have heard about Netbeans,
that it uses a really good GUI interface where i can use it as a WYSIWYG
to build my JPanel, so i installed it yesterday and tried to do a few
things and encountered some problems.

The first problem is, it seems i can't compile an existing .java file i
created. I can open it and view it fine, but i can't compile or run it at
all.

So then I referred to the tutorial and apparently I have to create a new
project first. So i did, and the project came with a demo class, and i was
able to compile and run it fine.

So this brings up my 2nd problem. After creating a project, I thought ok,
maybe i just need to add my existing .java files/classes to the project
and that'll work, but i've been trying to figure this part out for the
past 40 mins or so and read a lot of documentation and guides on Netbeans
and couldn't find out how.

Most of the guides i found were to add the .JAR files to the Libraries,
which is found by going to the project file and choose Properties. But my
files are in .java so not sure what to do here.


So basically, is there a way to simply compile and run the .java file in
Netbeans without opening a project?? And lastly, how do i add a .java file
to an existing project?


Please help me out, thanks.




Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> Java EE Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo