Advertisement

[java] Jbuilder4 questions

Started by May 14, 2001 12:24 AM
16 comments, last by Benzy54 23 years, 8 months ago
I recently got jbuilder4. Now i find out that i can''t make exe files. Can jbuilder make regular applications? I know it has all that sever and database stuff but for right now i just wanted to make a simple application. Can anybody help me??
From my understanding you don''t make exe files with java programs. You make class files that you run using the Java Runtime environment. So if you''re using the JDK, what you''d do is "compile" your .java file (using javac) and end up with a .class file which you would run using (java or javaw- java for command and javaw for windowed environment without the command window). At no point do you really end up with an exe file. Read your books, they cover this kind of thing. I''d also bet JBuilder 4 manuals would explain some of this too.
Advertisement
You''re right about the "usually" part... Java programs are normally not run as .exe files but with a virtual machine as .class files.
But with Visual J++ it is possible to create an .exe file. This is only since Microsoft uses Windows as operating system, so they added some extra features...
Don''t think that Borland included this too - they want their code to run on every OP.
Correct me if I''m wrong, though.

------------------------------

There are only 10 kinds of people: those that understand binary and those that don't.

Whenever you generate a new class using the wizard, click on the generate main method. Your class should then have a method with the signature of public static void main(String [] args){}
You can then run the class by compiling it (javac) or in JBuilder rebuild project, and then run it by java classname or in Jbuilder right click on the class in the left project view and click on run. This will run the main method. Remember it is static method so you must create a instance of the class inside the main method and you cannot access instance variables. If you need to pass in args, click on run, run configuration, new, choose your class, and then specify the argurments. Now you can click on the green arrow (actually black arrow next to it unless you made that class the default) and run and debug using that run configuration
I know how programs work with the main method and the arguments. I also have visual j++ and i knew that that created exe files which was really cool. Really question i still have though is this. Can i make a progam file with jbuilder and take it to another computer and run that program. Even though it doesn''t have jbuilder? I really appreciate your help on this to all that responded
Yes you can do that.
First you need to install the JRE - Java Runtime Environment on the other machine.
If you couldn''t do that you could also just copy all of the JRE files to a subdirectory in your project directory. Do a search on the Sun site for - distribution. I know I have read instructions made by them for this but can''t remember where. The subdirectory might need to be named java.
Advertisement
Geez,

Why couldn''t they have just made this easier. I mean can someone tell me why they made it so hard to do. Well i guess one could say if i knew what i was doing i wouldn''t be saying this. I don''t know this is so annoying. If you create an applet does it do this too or is it easier to implement it(deploy it). I am beginning to think that it was a mistake getting jbuilder. (Once again i am probably saying this out of frustration mixed with ignorance)
Once someone has got the JRE it''s easy to distribute java apps, just make "executable .jar" files:

Make a "manifest" file, with the lines:

Main-class: MyMainClassName


( NB, Remember to have a return after that line, it seems to matter).

Then run jar on your class files:

jar -cmf MyManifestFile.mf MyJarFile.jar *.class

You''ll then have a double-clickable jar file. Very handy. Also if you write your code correctly you can bundle all of your graphics inside the jar file, and have them loaded via that.
The other bonus is everything gets compressed.

jar file are great, the only problem is that it requires that the user has java setup right.
Thanks for the info i feel i am pretty close to actually doing it however, i use archive builder to make my jar files. It creates a manifest for me and i can''t seem to manipulate it. It does how ever get the main-class right and have everything that you said i needed.

when doing the archive builder thing it makes my jar file. I looked at what the manifest file says it it says this:

Manifest-Version: 1.0
Main-Class: calculator.CalcMain
(now this seems like it is what i want, but i can''t do anything to it like for example the return thing you told me to do)

The manifest''s file name is MANIFEST.MF(can i change this?)


when in the dos prompt

jar -cmf MyManifestFile.mf MyJarFile.jar *.class

I type in:

jar -cmf MANIFEST.MF calculator.jar *.class

now when it runs it gives an exception and tells me it can''t find the manifest file(MANIFEST.MF)

Is MANIFEST.mf a real file or what?
Musta forgot to put my name on my last reply

This topic is closed to new replies.

Advertisement