Java Forum / General / February 2007
NetBeans and JCreator
SBC News - 22 Feb 2007 22:29 GMT Hello Guru,
I'm new with Java and have a question regarding NetBeans and JCreator compatibility.
I have a Window Application program that I wrote using JCreator Pro 4.0. The program is compiling and running fine in JCreator Pro 4.0.
However, when I open the file in NetBeans, I don't have any way to compile/run the .java file. Is there a way that I can make the file works on both IDE environments? Or NetBeans just doesn't accept .java files that's not created using NetBeans?
Thanks, PETER NGUYEN
Lew - 23 Feb 2007 03:02 GMT > Hello Guru, > [quoted text clipped - 12 lines] > Thanks, > PETER NGUYEN Please post plain-text messages, not HTML, to newsgroups.
- Lew
Lew - 23 Feb 2007 03:20 GMT SBC News wrote:
>> I'm new with Java and have a question regarding NetBeans and JCreator >> compatibility. [quoted text clipped - 7 lines] >> Or NetBeans just doesn't accept .java files that's not created using >> NetBeans? NetBeans generally does not have trouble with .java files that come from "outside" its environment. What error(s) do you get when you try to compile or run your program?
Java is a very portable language, and programs written in one environment will work in the same revision level of Java pretty much anywhere (matters like JNI excepted). They also mostly work in later versions than where they originated. So if your program won't compile or run, there is a specific problem not related to whether "NetBeans just doesn't accept .java files", because it does.
It is hard to give good advice without specific information.
- Lew
SBC News - 23 Feb 2007 06:46 GMT Thanks Lew,
There is no error. It just simple does not give me the option to compile or run the .java file. All of the compile and run command are grayed out.
I can run the .class file (compiled with JCreator) from command line fine. I just want to make sure if I send the source code to my friend who uses NetBeans and he can compile/run my .java code.
Thanks, PETER NGUYEN
> SBC News wrote: >>> I'm new with Java and have a question regarding NetBeans and JCreator [quoted text clipped - 22 lines] > > - Lew Lew - 23 Feb 2007 23:18 GMT > Thanks Lew, Please do not top post.
> There is no error. > It just simple does not give me the option to compile or run the .java file. [quoted text clipped - 3 lines] > I just want to make sure if I send the source code to my friend who uses > NetBeans and he can compile/run my .java code. You probably need to set up a project for Netbeans to know the class path to the .java file, and where to put the compiled bytecode.
I have a project in my Netbeans set up for all kinds of "misc"ellaneous java files. When I want to run a single class, I stick it in a package within that project.
Don't forget that any Java compiler or execution has to be aware of the package structure. Avoid use of the default package.
- Lew
SBC News - 24 Feb 2007 00:05 GMT Hello Lew,
That is interesting. I've been using 'default package' sine I thought it default to NetBeans. So what you're saying is when I create a new project in NetBeans, I should give it a package name, so it does not create .java file in the 'default package', right?
 Signature PETER NGUYEN
>> Thanks Lew, > [quoted text clipped - 21 lines] > > - Lew Andrew Thompson - 24 Feb 2007 00:16 GMT > Hello Lew, > > That is interesting. What is?
Note that Lew also said..
> > Please do not top post. More information here.. http://www.physci.org/codes/javafaq.html#netiquette
Andrew T.
Lew - 24 Feb 2007 03:53 GMT "SBC News" wrote:
> I've been using 'default package' sine I thought it default to NetBeans. > So what you're saying is when I create a new project in NetBeans, I should > give it a package name, so it does not create .java file in the 'default > package', right? Not really.
First of all, the "default package" is a /Java/ concept, not Netbeans. It means a class that is not part of any package. It is for quick and dirty "toy" classes, not for real work.
Second of all, "it" does not create .java files, /you/ create .java files. Those are the source files that the programmer writes. The javac compiler program then creates .class files from those.
Third of all, you don't "give [a project] a package name", you put individual classes in packages. Packages organize and provide structure to groups of classes, and have important consequences to method and instance variable visibility. Consider, for example, the notion of "package-private", or "default" access.
Fourth of all, these are fundamental notions to Java programming, and are a little confusing because they relate to the directory structure where the .java and .class files reside. It will give you large dividends to study the Sun Java tutorial on the notions of classes and packages.
- Lew
Andrew Thompson - 23 Feb 2007 03:29 GMT ..
> I'm new with Java and have a question > regarding NetBeans and JCreator compatibility. Lew made some good points. In addition to those, I will simply add that since JCreator seems to offer Ant support, making an Ant based JCreator project might be a good way to make code portable between JCreator, NetBeans, Eclipse.. and even environments where people use 'TextPad and Ant'.
Andrew T.
David Segall - 23 Feb 2007 06:52 GMT >Hello Guru, > [quoted text clipped - 6 lines] >Is there a way that I can make the file works on both IDE environments? >Or NetBeans just doesn't accept .java files that's not created using NetBeans? Netbeans can be used with Java files from any source but it likes to arrange the directories in a "project" and write an Ant script to control the project. You can compile and run individual files in a project but you would normally compile and run the project.
Did you use the Wizard from the "New Project" menu to start a "General" "Java Project with Existing Sources"? The items in quotes in the previous sentence are from the menus and tabs you need to use. If you successfully filled in the fields the Wizard asked you for, what happened when you tried to run the project?
SBC News - 24 Feb 2007 00:05 GMT Hello David and All,
No, what I did was in NetBeans' File -> Open File and select my .java file. It opened the file but all of the Compile/Run icons/options are grayed out.
However, since the post, I did try to create empty project in NetBeans; then, copied the content of my .java file and pasted in the new project file and it compiled/ran o.k.
I'm O.K. now in a sense that I can work around, but still want to know why NetBeans behaved like this, though. I'm hoping you or someone that have more experiences in this field can point out the obvious. If not, I have to do it this way in the future.
Thank you all for your responses! PETER NGUYEN
>>Hello Guru, >> [quoted text clipped - 19 lines] > you successfully filled in the fields the Wizard asked you for, what > happened when you tried to run the project? Lew - 24 Feb 2007 03:58 GMT > what I did was in NetBeans' File -> Open File and select my .java file. > It opened the file but all of the Compile/Run icons/options are grayed out. [quoted text clipped - 7 lines] > experiences in this field can point out the obvious. If not, I have to do it > this way in the future. It was mentioned that Netbeans, indeed any Java compiler and executor, needs to know the classpath to compile and run a file. When you just open a file in Netbeans, you do not tell it any of that information. When you set up a project, that process tells Netbeans where the Java resources are.
(See David Segall's response, for example.)
A: Because it makes posts so dang hard to read.
Q: Why is it bad?
A: Placing answers above the questions you're answering, like this.
Q: What is top posting?
Please do not top post.
Note that you were given a link about the term, and GIYF, and Wikipedia has just about everything in it.
- Lew
Free MagazinesGet these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...
|
|
|