Author Topic: using code::blocks with the GJC compiler  (Read 6236 times)

svaens

  • Guest
using code::blocks with the GJC compiler
« on: August 21, 2007, 12:11:24 pm »
Hi,
Yeah. I would also like to be able to consider code::blocks as my IDE for java also.
I had a quick try at setting it up, but code::blocks seems firmly set to c/c++.....
I think perhaps if i would give my .java files a .cpp extension, i could trick it in to compiling the thing (with the gcj compiler, which I have set up as the selected compiler via the 'Global Compiler Settings ->Toolchain executables')

However, i don't want to have to 'trick' my IDE. I just want to use it. It would be nice.

Some have said 'why not just use eclipse' if you want an IDE for java.
Well, the reason I did not want to use eclipse for Java compilation is because Java is too slow. Why else do I want to be native compiling with GCJ, if not because I did not want the penalties of going through the JRE. Eclipse uses too many resources, and I never wanted to have to use it. I did not want to compile Java into anything but 'Native' (but i am interested in using the Java language). Hence my interest in using code::blocks, as a potential non-specific code compiler. It would be nice.

Do I have to trick code::blocks to compile my o/s native java app?
If yes, well, then I think i'll go somewhere else then.
If yes BUT, in the future code::blocks will be more flexible in this, then, i'll stick around.
If 'No' (I am currently doing something wrong in the setup). Then even better. Please help me out!

Kind regards,

svaens

p.s. I previously posted this somewhere else, but realised it was the wrong thread. Appologies.
:)

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: using code::blocks with the GJC compiler
« Reply #1 on: August 21, 2007, 02:02:38 pm »
I've never used it, but actually the Gnu Java compiler should be automatically invoked if you execute gcc with a Java file.... so this should work without any changes. (Hopefully?)

The only thing that remains then is opening Java files in the editor and having syntax colouring and everything, but that should work without problems, too.
I don't think we have syntax colouring for Java (never seen one) at this time, but by making a copy of the C++ one and editing a few lines, you should be able to get one in under 10 minutes.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

svaens

  • Guest
Re: using code::blocks with the GJC compiler
« Reply #2 on: August 21, 2007, 04:54:58 pm »
Thanks for the reply. Though I just wasn't sure how to go about telling the IDE that it should get the compiler to compile a .java file.

For example, If you add a .cpp file to a project, and right click on the file icon, the context menu will give you the option to 'Build'.
Also, if you do a project 'Build', all unbuilt files are compiled, and the whole thing linked etc.

If you load a .java file to the project (add file) there is no 'Build' option in the context menu,
and if you do a project 'Build' it tells you

"Skipping file (no compiler program set): test.java"

Question is, how do you tell code blocks what the compiler program for .java files is?

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: using code::blocks with the GJC compiler
« Reply #3 on: August 21, 2007, 07:20:00 pm »
Hmm... you can set the "compile" checkbox for individual files from the "properties" menu on each file. Of course that may quickly get annoying if you have a project with 500 sources...
I've done that in project that had 4-5 "alien" sources, works perfectly.

Apart from that, you can configure nearly every feature of the compiler plugin, just not what file extensions it recognizes as "compileable" automatically.  :?
You'd have to modify the sources (or make a custom compiler plugin) for that.
« Last Edit: August 21, 2007, 07:21:43 pm by thomas »
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

svaens

  • Guest
Re: using code::blocks with the GJC compiler
« Reply #4 on: August 22, 2007, 07:12:12 am »
hey thomas!

Thanks for your feedback.
Disappointing that It is not already configurable for java compilation...
BUT .... are you sure that direction "custom compiler plugin" would provide me with a fix?
As in, does the 'plugin' frame work provide me with the ability to provide such functionality?
While it doesn't come for free (as in, i have to write some code for it ;) ) it does sound interesting.
If, in doing so, i would provide myself with the solution I need, at the same time as providing extra functionality for the code blocks community. I might just have a look at it. Sounds a nice, non-invasive way, without having to directly modify the source.

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: using code::blocks with the GJC compiler
« Reply #5 on: August 22, 2007, 11:19:48 am »
Quote
Disappointing that It is not already configurable for java compilation...
Yeah well, Java was never intended as design goal (and still isn't). This doesn't necessarily mean Code::Blocks can't be used for it (you can edit HTML pages in Code::Blocks too), but it sure means that not everything runs out of the box seemlessly :)

Quote
BUT .... are you sure that direction "custom compiler plugin" would provide me with a fix?
Don't bother... I've changed two lines in the main application, so java files are treated as C++ from the build system's point of view. This is not all good and clean, but it means that if you use the GCC Java compiler, you can just add java files to your project, and hit the blue gear, and it will work.
It is a lot easier than all other solutions too, and should not cause problems and thus be acceptable for now (some day in the future the build system will be replaced anyway).

Note that this does not mean that we are supporting Java, nor does it make any claims that we will ever.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

svaens

  • Guest
Re: using code::blocks with the GJC compiler
« Reply #6 on: August 22, 2007, 11:35:16 am »
oh! ok. Thanks!

Nightly build (available 23rd august)??
I'll be happy with that for now then. And be watching for any official news for claims to support Java (or decisions to remove any existing support).

:)