New to linux, need help with Java

Code junkies hangout here

Moderators: ChrisThornett, LXF moderators

New to linux, need help with Java

Postby Hambo » Sun Jun 18, 2006 1:52 am

Hello!

I've been using FC4 for a while now, and I'm looking to replace windows with it, but one thing I need to be able to do is program in Java. I have been using RealJ in windows, which is an editor and compiler all in one. So i'm used to writing an applet project, then pressing the compiling button and being done with it. (Maybe theres a few debugs in there somewhere :) )

I'm still a tad uncomfortable with the command line in Linux, but I understand to compile my Java programs I will need to use the command line. I wrote a "Hello World" script in Text Editor and had a go at using the "gcj" command, and It threw up a few errors. I'm not too sure if I have to install anything additional to the Java development kit off the Fedora CD's to get this all working, but I assume I'm missing some librarys or something!

Any help in getting me started with using Java in linux would be appreciated!
Hambo
 
Posts: 34
Joined: Mon Jan 16, 2006 11:30 am

Re: New to linux, need help with Java

Postby emyr42 » Sun Jun 18, 2006 9:54 am

Hambo wrote:It threw up a few errors.


What were they?
OpenSUSE 10.2, WinXPHome
AMD Sempron 2400, 512MB DDR333, Twin 60GB Deathstars
User avatar
emyr42
LXF regular
 
Posts: 147
Joined: Tue Nov 22, 2005 9:16 am
Location: Cardiff, UK

RE: Re: New to linux, need help with Java

Postby GMorgan » Sun Jun 18, 2006 5:16 pm

Your best bet would be to get the Sun JDK first of all so you've got a complete Java implementation. I'm not sure how to achieve this in FC4 but I'm sure theres somebody here with the knowledge.

As for IDEs there is Kdevelop and Eclipse. Eclipse itself runs on Java so may be a good bet, I use Kdevelop but while it's got some Java options it hasn't a great list of them.

I'm not sure if you know that there is a FC5 out at the moment, thought I'd mention it just in case.
GMorgan
LXF regular
 
Posts: 684
Joined: Thu Jan 12, 2006 6:58 pm
Location: South Wales, UK

Postby TheDoctor » Sun Jun 18, 2006 5:27 pm

A few years ago, when I was programming in Java on a Windows machine, I used jEdit, which has a built-in function to start the Java compiler. The compiler you can download from Sun, as GMorgan suggests.

Since jEdit is itself written in Java, it should run under Linux, provided you've got the Java RTE installed, also avalable from Sun.

In principle, Java shoud be the least problematic of all programming languages to migrate. However, what should be straihtforward in pronciple isn't alway straightfoward in practice. So the best of luck.
TheDoctor
LXF regular
 
Posts: 325
Joined: Mon Jan 02, 2006 9:02 pm

Postby Hambo » Tue Jun 20, 2006 11:32 am

I had a look at Eclipse...gee its quite advanced. I wont be using stuff like that for awhile, I reckon. It makes RealJ look like a child's toy! I've only been learning Java for 2 months now, perhaps I should just stick to Windows and RealJ until I understand it all a tad better...

Thanks for the help, guys.
Hambo
 
Posts: 34
Joined: Mon Jan 16, 2006 11:30 am

Postby GMorgan » Tue Jun 20, 2006 11:02 pm

Remember that even with advanced IDE's you don't have to use all the functions ;) . Personally I think its good to start with an advanced one so you can get used to the lower level stuff that you will use time and again.

If you do decide to go back to Windows then good luck, Linux isn't going anywhere and your always welcome to try again in the future.
GMorgan
LXF regular
 
Posts: 684
Joined: Thu Jan 12, 2006 6:58 pm
Location: South Wales, UK

Postby TonyLB » Thu Jun 22, 2006 9:51 pm

Netbeans from Sun gives you a full IDE with a GUI design feature and you can run java code from within it, no need for the command line. It will also handle other non-java stuff like xslt. JBuilder is also free from Borland and is similar in many ways, but is bound to the packaged version of java it comes with. Again, run GUI and non-GUI code from inside the IDE (just click Run).
JEdit is a useful text editor for java code and has a plug-in compiler, jar builder and more.
BlueJ is a bit restricted but you can design, write, compile and run java from it. It has been built by a group of universities for teaching first year undergrads basic java programming.

Personally I like JEdit, and Netbeans for more complex projects.

Tony
TonyLB
LXF regular
 
Posts: 112
Joined: Tue Apr 12, 2005 7:08 pm
Location: Wirral, UK

Postby jjmac » Fri Jun 23, 2006 8:28 am

Howdy,


gcj is part of the gcc collection, not your java kit. You will likely need to set up some environment for it to use in your .profile/.bash_profile file ... CLASSPATH=

iirc something like ...

Code: Select all

gcj --classpath=<path> --main=classname file.java file.java <exename>

--classpath  :  appends to path
--main          :  class/java file with the main f() you want to enter with.
file.java       :  list of class/java src files.
exename     : desired exe.


should produce an executable ... The man page isn't to bad, the info file is much better but lacks actual examples.

I don't think java deserves its' portability hype. Once all the required class archives/paths/specific vm are set up, but thats par for whatever system is being used ... C has never needed such friggin around with my end. Premeditated macro based obfuscations by proprietary systems doesn't really count there. But a nice lang/env non the less :).

Getting all the CLASSPATH associations resolved is probably the main hassle, but once resolved ..., everything starts working.

Some systems will be setup to use a symlink pointing to a particular java/javac file, or use a script that resolves various issues. which can be obscuring sometimes. That is, a person thinks there using a particular java while the system trys to use another ... throwing the classpath resolutions all out :roll:. Incidently IBM's jikes isn't a bad package either , fast/straight forward.

Linux suffers from the licencing state of java. A lot of java packages will actually be installers for the kit instead of the actual package. So getting it installed isn't always as easy as it otherwise maybe.

Check the FC forum for specifics to java for the distro, i would think there would be some useful setup info there.

>>
I'm still a tad uncomfortable with the command line in Linux,
>>

It wont bite as much, as you may think. Much more powerful/stable than what your probably used to :)



good luck


jm
http://counter.li.org
#313537

The FVWM wm -=- www.fvwm.org -=-

Somebody stole my air guitar, It happened just the other day,
But it's ok, 'cause i've got a spare ...
jjmac
LXF regular
 
Posts: 1996
Joined: Fri Apr 08, 2005 1:32 am
Location: Sydney, Australia

Postby TonyLB » Sat Jun 24, 2006 4:57 pm

[quote="jjmac"]Howdy,

...
I don't think java deserves its' portability hype. Once all the required class archives/paths/specific vm are set up, but thats par for whatever system is being used ... C has never needed such friggin around with my end. Premeditated macro based obfuscations by proprietary systems doesn't really count there. But a nice lang/env non the less :).

Getting all the CLASSPATH associations resolved is probably the main hassle, but once resolved ..., everything starts working.
...
[end quote]

I had to develop a largish project and had to switch back and forth between Linux and Windows machines - partly for development and partly to make sure everything ran 'out of the box' on both. With java I could just use the already build class files, one of the reasons I rejected C/C++ since I didn't want the hassle of recompiling and so on. There are also some nice additional APIs like Java3D which provide higher level functionality than OpenGL, eg no need to code scenegraphs.

One problem though. The additonal libraries when ported to other operating systems tended to show different bugs to the Sun ones - frustrating!

Tony
TonyLB
LXF regular
 
Posts: 112
Joined: Tue Apr 12, 2005 7:08 pm
Location: Wirral, UK

Postby GMorgan » Sun Jun 25, 2006 12:47 pm

I think Java is hyped for portability since Bytecode is unreadable and only one step from binary. This allows an ISV to make a portable application without the need for source code. Of course for OSS Java becomes mostly redundant.
GMorgan
LXF regular
 
Posts: 684
Joined: Thu Jan 12, 2006 6:58 pm
Location: South Wales, UK

Postby jjmac » Mon Jun 26, 2006 11:38 am

Howdy TonyLB

>>
With java I could just use the already build class files, one of the reasons I rejected C/C++ since I didn't want the hassle of recompiling and so on.
>>

Yes, we can at least thank sun for that, i think if MS had their way, they would have introduced constructs to tie in development done on their platform. As they do with C/C++.

>>
one of the reasons I rejected C/C++ since I didn't want the hassle of recompiling and so on.
>>

hmmmm, a nice fast processor and reasonable ram would solve that. The run speed increase is worth it. Especially noticeable on lower MHz boxes. I can remember having to do quite a lot of editing on component anchor points (x/y) with java ports to Linux from windows. Due to MS using a different window decoration concept. But that was a few years ago. And i feel MS were at error there.

One problem that does just stare out with C, is the preprocessor problem. Warned on by Stroustroupe as well. And taken advantage of beautifully by MS. The WINMAIN macro MS use is a classic example. When i first traced that to an expansion for 'stdcall', (of all things) ... i just thought wtf !!!.

But then i realised, with such a simple construct, they managed to lock in all the rad generated code generated by gui's such as the CBuilder and others to their own platform. I would think that, true evil genius, must always be as simple.

I like the gcc approach in compiling java to native (gcj) too. I hope development on that facility continues to improve with time, as java is a nice language. I don't think i could live without pointers though (grin). I get kinda suspicious of systems when they try to govern out low level access/scrutiny ... well, my story anyway :) :).


>>
One problem though. The additional libraries when ported to other operating systems tended to show different bugs to the Sun ones - frustrating!
>>

Yep, time time, templates are apparently getting better, (grin).

GMorgan wrote:
>>
I think Java is hyped for portability since Bytecode is unreadable and only one step from binary
>>

I was only meaning that the portability depends on a vm being available for the platform. C/C++ is a very portable language, as long as it's written with that goal in mind. Such as using 'long' rather than 'int'. As i've been taught can be helpful in endingness and 32/64 bit concerns. And it does make sense. Plus, unavoidable plate form issues can be dealt with by the configure stage of a build. I think Sun were expressing a design goal more than anything. And that goals success depends on all the other companies playing ball so to speak, as is the case with C. so there isn't a lot of difference there.

I think i must have 'goal' and 'ball' on the mind at the moment for some reason :)


jm
http://counter.li.org
#313537

The FVWM wm -=- www.fvwm.org -=-

Somebody stole my air guitar, It happened just the other day,
But it's ok, 'cause i've got a spare ...
jjmac
LXF regular
 
Posts: 1996
Joined: Fri Apr 08, 2005 1:32 am
Location: Sydney, Australia

Postby Hambo » Tue Jun 27, 2006 7:15 am

*sigh*. I still havent had much luck. The IDE's are all mighty and powerful, but I still havent written a single applet that works, and I've got no idea how to write an actual application yet. So it's back to stupid, stupid windows.

This just illustrates the dependancy people have on Windows. I probably could find a program somewhere that I could write applets in for linux, but why bother when I allready have one that I've been taught to use well?

And thats what really pisses me off, because what I'm taught with in school, I'll probably allways use. How the hell can Microsoft be allowed to have a monopoly, or complete control of what goes on school computers?

For now, I'm still dual booting. Until I leave school, I'll still have to have it on my computer. The fact that I pirated my copy of Windows makes me feel better now.
Hambo
 
Posts: 34
Joined: Mon Jan 16, 2006 11:30 am

Postby jjmac » Thu Jun 29, 2006 12:11 am

>>
and I've got no idea how to write an actual application yet. So it's back to stupid, stupid windows
>>

Use its' eamples, info, etc ... :wink:


Why not just take some applet code from windows, smallish stuff, and copy it over to Linux. Then work on getting those to compile. Going through the tracing of different classpaths etc. Once those initial 'ground work' concerns are nutted out ... put it all in a 'Makefile' for java. There are qiute a lot of facilities all ready on most Linux boxes, regardless of any specific ide/rad environments. A lot of editors have programing modes for example. I use 'emacs' quite successfully for that, but other editors function just as well. Getting all the preliminaries in order is probably the most difficult part. But then again, thats basically what programing is about, and i think it's good to do those traces. As it reveals how your system is setup, and whats hidden away and where.
You may be bring an MS expectation over to your Linux experiments and finding an understandable struggle as a result. That wont work in the longer run.

Just to divert off java for a bit. If your ever looking for a light weight designer, 'FLTK' is a very functional app -=- The Free Light Toolkit -=- It's just a gui/component designer, 'form' and 'pallet', but very smooth. Basically a wrapper for Athena widgets. I use it for any gui related personal stuff and quite like the way it doesn't try to impose a whole lot of auto generation on me, that personally, i can really do without. The way some will auto generate around 250 to 400 k of useless configuration/Makefile stuff just for a two line 'hello world' expression really pips me at times (grin) :)


jm
http://counter.li.org
#313537

The FVWM wm -=- www.fvwm.org -=-

Somebody stole my air guitar, It happened just the other day,
But it's ok, 'cause i've got a spare ...
jjmac
LXF regular
 
Posts: 1996
Joined: Fri Apr 08, 2005 1:32 am
Location: Sydney, Australia


Return to Programming

Who is online

Users browsing this forum: No registered users and 1 guest