NetBeans - how to add java files

Posted on 2006-05-06
Last Modified: 2010-03-31
I want to compile a .java file but netbeans seems to prompt me to
create a new project first. Do i always need to create a new
project before i can compile the java files?

I created a new project, how do i add the pre-completed .java files in..
Question by:jedistar
    LVL 14

    Expert Comment

    Do i always need to create a new project before i can compile the java files?

    yes. you can add your java files to currently generated projects too

    > how do i add the pre-completed .java files in..

    netbeans takes responsibility to compile java source files for you
    LVL 14

    Expert Comment

    what do you mean by pre-completed .java files ?
    LVL 14

    Accepted Solution

    you mean how to add existing source codes in existing projects ?

    I think there is no general way to do this
    one way is to create an empty class file and copy/paste the content of the existing source into it

    another way I have just found, is simply copy/paste the source file into sproject's src folder, and it will be added to netbeans automatically
    LVL 23

    Expert Comment

    >> how do i add the pre-completed .java files in..

    I think you have a .class file is it or you just have a java file which is out of the project.

    ok assuming you have a java file what you need to do is create a java file with samr name and package structure and add the content of the existing file to it later.(beacuse netbeans doen't allow you to copy and paste the file).

    if you have a .class file the if you want to use this is writing some other program which makes use of this .class file then you include it in the libraries folder of you created new project.

    Thank You.


    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    Suggested Solutions

    For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
    Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
    Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now