Netbeans create Java source files in a C/C++ project - netbeans

I have recently started using Netbeans C/C++. I see that the new file wizard doesn't show any buttons to create java files, all of them disabled. I can create java files in a Java project however.
If I create a java file manually and open it inside the ide, it provides syntax-highlighting. But the IDE doesn not show any wizards that will enable me to create new java files inside a c/c++ project.
How can I enable this ?

You can't create Java files in a C / C++ project (and vice versa) . You have to use either Java or C(++).
I don't see a reason why you should mix them, but better you develop your Java code in a Java Project and same for C/C++. However, you have to move manually.
Btw. please explain your problem more detailed, it's hard to understand why you put two (or 3) totally different things together.

An observation, rather than a solution...
We need to support mixed language projects because the dependancies between artefacts-by-language can go in both directions.
For example: Java classes are used to generate JNI headers (javah) for C/C++, while C/C++ headers/libraries are used to generate wrapper classes (swig) for Java.
This represents a bidirectional dependancy between single-language projects, but not between artefacts in a single mixed language project - i.e. the build can be described by a DAG and thus satisfied by make.

Related

Eclipse CDT: combine a make project with a cmake one

I have a standard C project in Eclipse CDT. Naturally it uses make. I have decided to add some JSON support to my application to be able to load/save its configuration in a readable format that the user (if such desire occurs) can alter those manually and/or through an external tool. I've looked up two options so far namely Jansson and Json-C. The problem is that both are using cmake, which, if I recall correctly, can be imported in Eclipse CDT without problems (though in itself CDT can't create cmake projects).
I was thinking of adding a script for the pre-build step of my project that runs cmake (as an external command) and sets up the JSON library (static and/or dynamic) so that when the build process of my projects starts the library file will be available.
Is there a better way to combine a cmake with a make project in Eclipse CDT? I know that cmake basically generates a Makefile but I've never done such a combination before.
Even if there is a JSON C library somewhere out ther that uses make (I'm 99.9% sure there is such thing :D) I'd still like to know how to tackle this situation.

Using CDT without Eclipse

I want to use CDT parser in a project. The project would be a command-line, stand-alone project, i.e., not an Eclipse plugin.
All solutions that I've seen requires using a IWorkspace. But, I want to use the CDT parser on single files outside eclipse. Is there any way to do that?
It depends what you mean by "without Eclipse".
CDT's code is built on top of the Eclipse Platform, so you're going to need to be running an application that includes the Eclipse Platform. However, there's no reason that application can't be a command-line application. These are called "headless" applications in the Eclipse community, and you can find many tutorials for making one (here's one).
Requiring an IWorkspace shouldn't be a problem. You can e.g. create a workspace and a project in a temporary folder, and copy the code to be analyzed there.
If, for some reason, you really want to use just CDT's parser in an application that doesn't include the Eclipse Platform, you can probably copy the parser code from CDT, and replace any dependencies it has on the Eclipse Platform with your own implementations. However, this is likely to be a more labour-intensive approach, and I wouldn't recommend it.

How to create a Processing Language plugin for Eclipse?

I'm quite a noob programmer and I recently discovered Java Processing Language which can be run on Android.
So far I've been using a dedicated IDE to program it in but I've just found out I can program it in Eclipse which is my preferred IDE. The only problem is that they only tell you which libraries to import when creating a Processing project from a standard Java project. So every time I want to create a new project I have to create a Java project, go through all the import menus, search for the Processing system library, import the files, create a new class and import the library for the class.
Does anyone know how to create an eclipse plugin so I can just go to the NEW directory in eclipse and have a PROCESSING folder and a NEW PROCESSING PROJECT item that already has a generic class with the imported libraries?
I've been looking at online tutorials and I can't even figure out where to start.
The steps to create a Processing project from a Java one are explained here.
Thanks for any help!
I recommend having a look at the Proclipsing plugin which seems to do pretty much what you want to achieve. It's also open source so you can see how it was written and modify if you like.
A Processing project is a standard Java project with the Processing libraries added to build path. There is nothing more to Processing in this regard. So a specific Eclipse Processing plugin for this seems overkill (there are some other things like the different targets or samples that could make it useful though).
To easen up your current process: Create an Eclipse User Library for the Processing libraries. Menu Window > Preferences, Java > Build Path > User Libraries, New.... Add the Processing libraries. Now you can easily add the whole set to a project (right-click on the newly created Java project in the package explorer, Build Path > Add libraries > User Library).
If you want to change the standard template for Java classes to one including everything for Processing: Window > Preferences, Java > Code Style > Code Templates, Code > New Java files. This changes every newly created class, maybe it is better to just create a simple template to manually call at start: Java > Editor > Templates, New.... Then you would call the template every time you create a Processing main class but not for "normal" classes.
Ok... regarding the target audience of Processing a plugin may be a good idea. But then there is the dedicated Processing UI. Eclipse is not exactly a good introductory IDE.

How do I run an arbitrary java file with Eclipse?

I need to run some example java code. I like using eclipse because it shows the methods, properties, constructors and so on. The problem I'd like to solve is that unless I create a new project I can't compile and run the example code I'm using! Is there a way around this?
No, there is no way around this. A Java file is very rarely a self-contained program with no dependencies at all. Most of the time, a program is composed of many collaborating classes depending on external libraries.
If you just want to test a self-contained Java program consisting of just one java file, then create a "playground" eclipse project, drop this file inside this project, and run it. Use the same playground project for all the other self-contained java programs if you want: you may have several main classes inside a single eclipse project.

Creating ANT file for use in Eclipse and CruiseControl

I have a project in Eclipse that currently has no ANT build file, but is about to have one created (to facilitate building jars). I'd like to write the build file so that it would work for both. I was just going to write the full build in ANT but I noticed this line in an IBM Help doc.
The Java builder runs the internal
Eclipse Java compiler which in turn is
responsible for indexing your source
so that searching, refactoring and
many other features are available.
Thus it is not possible to replace the
internal Eclipse Java compiler by
using a project builder. You can
disable the Java builder and you can
control when the Java Builder runs
with respect to the project builders
that you define.
Do I need to write the ANT file so that it conditionally compiles (javac) only outside Eclipse? Are there other things I need to do to make ANT and Eclipse play nicely together?
There are maybe more sophisticated approaches, but here's what works for me. Just set up your Java project in Eclipse to output classes to the same dir as your Ant buildfile does. Let Eclipse compile your project using normal Java compiler.
During typical development, you will probably be changing Java source files and wanting to see that they compile. The Eclipse Java compiler will take care of this. Less frequently you will need to rebuild jars. Ant will take care of that. You can kick off the Ant build when you need to from the command line or from Eclipse.