• Welcome to Computer Association of SIUE - Forums.
 

Cross Platform Java - I need help

Started by raptor, 2008-06-16T10:29:15-05:00 (Monday)

Previous topic - Next topic

raptor

Okay,

My senior project involves developing a cross platfrom java application.  We are currently using the Netbeans IDE (in windows).  BUT!!! when we take our application over to a Mac it crashes and burns.  Now, I do know that Mac's are only upto Java v5 (i think its 1.5 for a Mac) not v6.  So, we have tried building an application with v5 and still no luck. 

Does anyone have any idea what I need to do.  I'm not sure if I'm using the wrong version on my windows machine, or if I'm not doing something properly when I build the app before taking it to a Mac.

Scott
President of CAOS
Software Engineer NASA Nspires/Roses Grant

Gregory Bartholomew

I'm not sure if this is true for macs, but many modern linux'es have been coming with gcj (gnu java) rather than sun's java because until very recently, sun's java could not be distributed under the gpl.  You probably need to install sun's java on your mac.

Use "java -version" to find out what brand of java is installed on the system.

Sun's will report something like:

[root@home ~]# java -version
java version "1.6.0_04"
Java(TM) SE Runtime Environment (build 1.6.0_04-b12)
Java HotSpot(TM) Server VM (build 10.0-b19, mixed mode)

Whereas GNU's will report something like:

[root@home ~]# /usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/bin/java -version
java version "1.5.0"
gij (GNU libgcj) version 4.1.2 20070925 (Red Hat 4.1.2-27)

Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

gb
......

raptor

it is running sun's java version 1.5._013 i believe.  Which if i'm not mistaken is comparable to 5.0 for windows.
President of CAOS
Software Engineer NASA Nspires/Roses Grant

Gregory Bartholomew

If it is crashing at runtime, not compile time, it may be that you do not have you CLASSPATH environment variable set up properly on the mac.

Other than that, I don't know what the problem could be.  Perhaps if you posted the error codes?

gb
......

William Grim

Quote from: raptor on 2008-06-16T10:29:15-05:00 (Monday)
Okay,

My senior project involves developing a cross platfrom java application.  We are currently using the Netbeans IDE (in windows).  BUT!!! when we take our application over to a Mac it crashes and burns.  Now, I do know that Mac's are only upto Java v5 (i think its 1.5 for a Mac) not v6.  So, we have tried building an application with v5 and still no luck.

Depending on your version of Mac and OS X, you can get Java SE 6 here: http://developer.apple.com/java/.

What is the stack trace of your crash?
William Grim
IT Associate, Morgan Stanley

raptor

I dont' have a Mac with me to get the error report, but the CLASSPATH error sounds very familiar.  How would I go about correcting that issue.
President of CAOS
Software Engineer NASA Nspires/Roses Grant

Gregory Bartholomew

It depends on exactly how your software was written.  Most small java applications have all their class libraries in a single directory, in which case, typing something like "export CLASSPATH=.:${CLASSPATH}" before running you application might work.  A lot of those fancy IDE's like to make a mess of things, however, by putting things inside of "packages"/subdirectories.  That's one reason why I favoured using vim the last time that I wrote a java application.

gb
......

raptor

Hmm interesting.  So whatever happened to making a self contained executable :S
President of CAOS
Software Engineer NASA Nspires/Roses Grant

William Grim

Quote from: raptor on 2008-06-17T14:11:07-05:00 (Tuesday)
Hmm interesting.  So whatever happened to making a self contained executable :S

You can still make them if you want to import the .class files directly into your project.  If it's a CLASSPATH issue, then you need to make sure you setup your CLASSPATH correctly in whatever IDE you're using.  You should also create a shell script around your Java executable that always sets the CLASSPATH for you; this is how a real Java project would get released anyway.  Maybe Apache's Maven has some help for handling Java project dependencies automatically, but I haven't used it yet.

Also, on an slight tangent, IDEs putting Java code into packages is a function of Java, not the IDEs.  I would avoid vim for any real Java work and reap the benefits an IDE has for any projects over 1 file in size.
William Grim
IT Associate, Morgan Stanley

raptor

Thanks for all the help guys.  Looks like I know what direction to look in from here.
President of CAOS
Software Engineer NASA Nspires/Roses Grant

Tony

Also, how are you going about compiling your project on the Mac and is it crashing at compile time or runtime?

The IDE should have generated a build.xml file.  If you have ANT on the Mac you can just call that build.xml file by typing "ant" in the directory where the build.xml file is.  Or if it has a "clean" and "deploy" command in the build.xml you can just type "ant clean deploy" in the directory of the build.xml file.

If you are already doing this, sorry. :D
I would rather be hated for doing what I believe in, than loved for doing what I don't.

raptor

sure wasn't.  I should have prefaced with A) I have never done Java development B) never used netbeans C) never programmed anything on or for a Mac
President of CAOS
Software Engineer NASA Nspires/Roses Grant