NetBeans and JCreator

S

SBC News

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
 
L

Lew

SBC said:
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

Please post plain-text messages, not HTML, to newsgroups.

- Lew
 
L

Lew

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
 
A

Andrew Thompson

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.
 
S

SBC News

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
 
D

David Segall

SBC News said:
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?
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?
 
L

Lew

SBC said:
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.
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.

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
 
S

SBC News

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
 
S

SBC News

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?
 
L

Lew

SBC News said:
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
 
L

Lew

SBC said:
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.

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top