• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • Carey Brown
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • fred rosenberger
  • salvin francis

Stand Alone Apps

 
Ranch Hand
Posts: 238
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, I haven't asked a stupid question in at least 2 weeks, so...
Can you create a stand alone application with java or do you have to have it on a server and serve it from a web "outlet"?
 
Ranch Hand
Posts: 1055
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Sam Smoot:
Ok, I haven't asked a stupid question in at least 2 weeks, so...
Can you create a stand alone application with java or do you have to have it on a server and serve it from a web "outlet"?


Servlets have to run inside a web container, since the container implements most of the servlet interfaces, and manages certain objects (including servlet instances). Standalone apps will run on a machine that has a JVM in it.
 
Sam Smoot
Ranch Hand
Posts: 238
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That I understood, but I'm wondering if there will ever be a "day" that you can write an application in Java and not have to depend on a server to host it (for application or servlet processing) and just be able to write programs for the general "user" to access without having them to add plugins to their machines. Since the JVM is an (almost) integrated part of the OS (if Micro$oft would ever get a real life and stop changing things mid-stream) then this could be conciveably possible, yes? (Kiinda like writing an application in C[whatever] and installing it on the machine, without the hassle of having to cross compile it to different systems...)
Just curious...
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, yeah.
Some of the applications that we have at our place are stand alone. They just install on the C: drive or whatever and run from an icon with no browser, no server etc. Some of them run on the client and then have a server side also.

Is that your question?
 
Cindy Glass
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is a small stand alone application.
Compile it.
Open a DOS window and execute
>java Test
 
Sam Smoot
Ranch Hand
Posts: 238
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think so... I guess what I'm wondering is if I write an application, say, to update/maintain a mailing list (cheesy example, but it works) but not have the program run anywhere but the desktop. If I just used text files and put a .jar file containing all my compiled code, it should run like it was a .exe application if they click on an Icon (and they have the JVM on their machine). Of course, if I could tie into a database (JDBC) without the user having to run a server in the background, that would be nicer.
I would, however like to run it in gui (AWT /SWING) window instead of having the user run to dos when they wanted to run the app. I guess I would have to create a batch file and incorporate javaw.exe or something similar in the .jar file to have it execute without a dos window... yes?
Just thinking (which got me into trouble in the 1st marraige :roll: ) and/or wondering if this was possible...
Thanks.
[ September 30, 2002: Message edited by: Sam Smoot ]
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you seen Netscape 6? It was written in Java and runs as a stand-alone executable. I don't necessarily know *how* they did it, but it shows that it *can* be done. Many of the tools that come with the latest version of Oracle were written in Java, too. I'm sure there's a way to create an exe file from all those class files.
Of course, you could just as easily create a Windows shortcut that runs "java MyApp". Where MyApp is the class file with main() in it. I doubt this is exactly what you are looking for, though.
 
Sam Smoot
Ranch Hand
Posts: 238
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are a couple of tools to create exe's from Java, but it defeats the purpose of Java, namely platform independance. I've looked at that, too, but it isn't the way I'd like to go.. I may check into Netscape's trick... may be useful...
 
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I still don't understand what you are after. Perhaps it will help if we write out possible instructions to the user.
Is this something like what you want to be able to tell the user?
1) To install the program on your computer, copy your Windows desktop. It will have the name MailingList.jar.
2) To run the program, double-click the MailingList.jar file on your Windows desktop, and wait for the program to start.
It looked like you were saying you knew how to do this, but then you mention a DOS window.
 
Cindy Glass
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You sound like you are understanding it.
Our applications all run on Windows so we have a .bat file that resets the classpath (because we bundle a JRE with the app - just to be SURE, and we want to point at that one) and invokes the app. The bat file is hooked to an icon. It is only in test that I invoke an application from inside the DOS window.
You can JDBC to a remote Database without having an app server in the picture - that would make it a 2-tier architecture. If there were a GUI peice, a server piece and a Database piece then it would be a 3 tier architecture.
 
Sam Smoot
Ranch Hand
Posts: 238
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, the scary part is I'm begining to understand what you're saying, Cindy. 6 months ago, it would have been much different. I just need to make sure that a jre is bundled with the .jar so that the user installs what I want them to run.
Is there a way to detect whether a user has the/a JRE already installed on their machine or should I just go ahead and install it no matter what? What would be the best way to build an install shell for this kind of app? Also, if I have a GUI and a database (JDBC), that would be a 2 tier and I would have to make sure they used the correct/same version of a database package (access, foxpro, etc.) to have the access to the data, right?
(Ok... I'm on a roll now.... gotta keep momentum or phubbbtttt! it's gone....)
 
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Sam Smoot:
There are a couple of tools to create exe's from Java, but it defeats the purpose of Java, namely platform independance. I've looked at that, too, but it isn't the way I'd like to go.. I may check into Netscape's trick... may be useful...


Not sure about Netscrape specifically, but most executables that wrap java code use the Invocation API part of the Java Native Interface (JNI).
You can see how this might work by looking in the src.jar that came with your JDK - in the launcher folder is source for the java executable (java.c). Most of what's in there is command line processing and stuff. The part to launch java and run some method on a class is pretty straightforward. This of couse has to be compiled to a platform-specific thing, but it's simple enough that getting it to compile on multiple platforms is not a big deal.
And remember that if you have a script, that's platform specific too - you will need at least 2: one for windoze and one for unix. (That is, if you're good at Borne shell you can usually make one script work for several unix flavors). And if you're going to support desktop icons on unix, there are several flavors to deal with there (although KDE and maybe Gnome on Linux would probably be sufficient).
Another option for install of your app and jre and dropping an icon on the desktop, etc is Java Web Start. It assumes you have a web server somewhere that the user would download the app from, but that's probably not too big a stretch. I think you can set things up to auto upgrade, and stuff like that.
http://java.sun.com/products/javawebstart/
I haven't had a chance to play with WebStart yet, so I can't be much more help than just pointing out the url.
 
Cindy Glass
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We use InstallSheild which bundles the application with a JRE and a properites file and an .ico file for the icon etc.
This creates an .exe file that is downloadable from a web page and the user just double clicks it and it all self installs.
 
Sam Smoot
Ranch Hand
Posts: 238
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Cool! Now I can be really dangerous... may actually write somthing useful!!
Thanks for the Help!
 
Hey, check out my mega multi devastator cannon. It's wicked. It makes this tiny ad look weak:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic