How to put java application on the web? - java

I am writing a minesweeper program in Netbeans, with java. I would like my friends to be able to try it, preferably on from there own computer, over the web. I have already made a .jar file, but do not know if how to proceed, or even if this is possible. How would I put it on the web so they can try it out?

Why not just send them the jar file? Then, they can just run it on their computer.
To put the program in a webpage, you need to put it in an applet, which will require some extra work (and maybe some changes to your code).
http://java.sun.com/applets/

You need JavaWS (Java Web start )
Check this link
http://docs.oracle.com/javase/1.5.0/docs/guide/javaws/developersguide/syntax.html

One option is to write your game as an Applet.
See the standard tutorial or you can google for many others.

Related

How to make laravel executable using Java?

Any Idea/Suggestion how to wrap laravel so it becomes executable with Java Program?
So the idea is I'd like to create a GUI using Java for doing laravel command like serve, queue:work, migrate, etc. Thus the threads/processes are handled GUI-ly by Java.
But as we know, laravel requires so many prerequisites to be installed first, for instance, PHP and mySQL.
Wouldn't it be great to provide a GUI to control all of that? So all the administrators need to do, just extract my app, open the java GUI app, click start button, and voila! it's served.
Thank you in advance!
RESOLUTION:
Developing another app to run a standalone webserver is almost impossible if not impossible. So I decided to create a VM to run everything.

How to avoid providing path in the code in Java swing

I have an Exe file created using Java Swing. I recently added a below code to open multiple session of an application at the same time. It works fine.
Runtime.getRuntime().exec("C:\Auto\format.exe")
The application is used by different users and hence they are forced to save the application on the same path. If not, they would be able to open multiple sessions.
How do I avoid using path here on this code or Is there a better option for me?
Thanks in Advance.
You could get rid of the path, when your *.exe file is in the same folder or subfolder of your Java program.
The only thing you need to care about is, that of your program is installed on somes computer, that you take the *.exe with you. You just could copy the files or you could create an installer (my suggestion).

How to put java code into an application format?

I made a simple command-line based game in java, only two classes (using Eclipse). But I was wondering how I can make this into a usable application for anyone, without running it through eclipse (ie send it to someone who knows nothing about java but would still be able to play the game)? Thanks!
You want to create a runnable jar file.
Eclipse has an option for this in the "Export" menu. For more options, search for "executable jar file" here or on Google.
You want to make sure that you also include any jar files your code depends on as well (Eclipse can also do that for you).
Users will be able to start this by double-clicking on the file on most platforms. If you need better integration (such as a custom icon), you will need to bundle it up further into an OS-specific executable. But for starters, a simple runnable jar works fine.
send it to someone who knows nothing about java
You need to get them to at least install the Java runtime on their machine (if it is not already there).
Just to be clear, "command-line" and "knows nothing about java" are probably not going to work very well for you given that:
java is OS agnostic, therefore, if you send (presumably) a jar file to say...your grandma and she has a mac and you have a PC chances are her getting it to work is not going to be "out of the box easy" so to speak.
Left with this, I think you have a couple choices...first off, you do need to package your classes - a runnable jar will work fine. Aside from that, you will most likely have to build OS specific scripts (batch scripts for Windows, shell scripts for unix, etc.) and you will have to hand these out with your jar file. That being said, the intended user will still need to have java installed, and the batch scripts themselves are not likely to be trivial endeavors.
Your next option would be to use JNLP. However, I don't think JNLP has a command line mode, so you will likely have to simulate a console with something like a JTextArea.
As far as I see it, your last option it to use one of the many products (not sure if there are any free ones) that package java into native code. I think Exe4j is one such example - but, like I said, I am not sure if there are any free ones and I am not sure how hard they are to use.
Best of luck, and if you can't get your jar to work you should probably move that to its own question.

Using a Java program I made on a Web Server

I created a small application that, when run, creates or updates some tables in a database by extracting data from some PDF files. Everything works fine in this desktop application, but the next step for me would be to make it possible for an administrator on a website to upload a PDF file and my Java program would then run and update the tables accordingly.
The problem is I have no idea where to start with this (the site isn't done yet, but I'm running some tests and it is going to be coded in PHP). I'd like to know what kind of technologies I need to let the server run the program and update everything as it would in the offline version. Sometimes it takes a while to update everything, so ideally, the user uploading the PDF could continue browsing other pages while the server does its job. (I'll probably implement something that when the server is done processing the file, it says if the program ended successfully or not in a log file)
Can someone tell me what terms to search for on Google or give me some pointers? I haven't chosen where my website is going to be hosted either, so if someone could tell me what to look for to know if they support running applications like this, I'd really appreciate it as well!
This could also apply to other programming languages as I know a bit of Python and C++ as well, so in the future I might have some applications in those languages I'll want to use on the web.
If I'm not approaching this the right way, I'm open to other suggestions, but the best solution would be to keep my Java program intact as I know it works exactly like I want it to and I'd rather not have to start it all over again.
If your host is *NIX based you can use crontab (Automatic Task Scheduler) to run your program at set intervals. Make it check if a "new" PDF exists, and run the program if there is. There may be a way to use Windows Task Scheduler type programs to do it on Windows. This is probably the easiest way.
Alternately you can use You can use shell_exec() in your php to execute a command on your *NIX system directly to run your java program.

I want to check open applications before turn off my computer through java program

Actually I am working on a java based application which has a functionality to turn off my system on a specific time and it's working fine but, the requirement says that if any application is open then it should not be close before turn off my system must have to close all the open application manually.
I am unable to find out the solution.
I have never tried this but it looks like you would have to use: Runtime.getRuntime().exec(). This seems to be a pretty good example of how to do this.
Java JNI
https://github.com/twall/jna/
Get the list of all processes via WinAPI and check for user_name in PEB of a process.
Or this http://msdn.microsoft.com/en-us/library/aa390460(v=vs.85).aspx :)

Categories