networking applets not working in chrome - java

I have recently created a Java applet which creates a socket and performs some networking functions. The applet works fine when run in an applet viewer. But when i try to run it in a
google chrome, it is launched but its not performing the desired function.
I used (ofcourse) java.net library and my applet runs without a main method.(Old applets unlike swing components).
Is not having a main method a problem ??? Please help :) thanx

Actually after a bit of research i came to know that Java applets have many restrictions due to security reasons... which include specially on creating the SOCKETS!!.
If you really wanted to communicate using Applet then you have to run it independently, to accomplish this you should have the applet digitally signed which is too tough to obtain.
Instead you can create the JAR version of the applet and then convert into exe application using jar2exe converter and use it.

Related

Publishing a .jar game online

I have created a simple java game and received a .jar file. I want to publish this game online on game websites (flash game websites such as kongregate, miniclip, etc.) but am unaware as how i would go about doing this. I have read that you create an applet to post the game online; but can I do that for a website that i am unable to edit?
TLDR: How to post .jar file on website, & if you do so via applet, can someone who cannot edit the site create an applet for the website?
If it is the latter can someone guide me towards a guide for creating an applet?
How to post .jar file on website, & if you do so via applet, can someone who cannot edit the site create an applet for the website?
Short answer, no. Long answer, nope.
In fact, it surprises me that you would think that you can launch an applet from a site when you cannot edit it! If that were possible, I could insert spam ads in a site that is supposedly under your control!
As to deploying the application:
The best way to deploy a Java desktop application is using Java Web Start. A JWS app. can be launched from a link on a web site.
It is a lot easier to deploy a JWS app. than it is to deploy applets (which, BTW, soon won't be supported in Chrome or IE at all, and are by default blocked in Safari and FF).
You will still need 'edit permission' on the site to launch a JWS app. As well as the ability to add new files to the site (e.g. the Jars(s) & the JNLP file used to launch the app.).
Lastly, either applets or JWS will need to be digitally signed by a valid certificate before there is a good chance of the JRE allowing them to launch.
I have created a simple java..
Not looking so simple now, is it? ;)
Deployment is typically a lot harder than people expect, and in the case of 'simple apps.' harder than they were to code and debug..

How to let java applet download file

I am new to Java Applets.
I have the following situation: the client asks for a Java Applet to do Function1, i already have this Function1 developed and tested but in C#. so i say that i can use my C# dlls in Java applet.
I already tried to use UnmanagedExports and it works fine with simple cases, but i faced a problem when i have dependencies for the dll that is called from Java Applet. the problem is that Java Applet crashes when the dll have any dependencies and i did not find any solution for this case.
My Questions are:
1- How to solve dependencies problem using UnmanagedExports?
2- If no solution for problem 1, what is the best approach that i should use to complete this task.
I think that Java Applets can setup an application on client PC, this application can run on a standalone app context (this application will be a c# application that can perform the task on the background and gives the feedback to the Java Applet). Is this possible?
To answer your first question, try Dependency Walker for resolving dependencies for a specific DLL.

What is the best way to turn this Java Swing application into a sandboxed embed-able (applet or Web Start)?

I am working on a primitive online game client that I wrote as a Java Swing application. My problem is that potential users refuse to download and run any unfamiliar executable. I want my game to be reach as many people as possible and users fear that the executable might contain a virus. That is why I would like to embed the game client into my web page instead. How would you turn this Java executable code (liked below) into an applet?
Thus far I have a main which makes the initial connection to the game server...
https://dl.dropboxusercontent.com/u/214507961/Main.java
A Java Swing GUI that I made with the Netbeans GUI builder...
https://dl.dropboxusercontent.com/u/214507961/GUI.form
Object input/output streams connected to my game/web server...
https://dl.dropboxusercontent.com/u/214507961/Clients_Input.java
https://dl.dropboxusercontent.com/u/214507961/Clients_Output.java
And some buffered images for graphics...
https://dl.dropboxusercontent.com/u/214507961/Image_Repo.java
Note that in future development, I would like to replace much of the primitive looking 2D Swing GUI with content rendered with the Lightweight Java Game Library or some other higher-level video game graphics specific library to make the game look better.
Given that information, what is the best way to make this Java application into an embed-able (applet)? Describe your method and reasoning in such a way that even a college freshman could follow.
Note: Following the advice below, I have tried using WebStart, but I still get an intimidating warning:
Update:
I am in the process of refactoring my code so that the top level container is a JPanel.
I have tried making "GUI" extend JPanel and changing the "gamewindow" from a JFrame into a JPanel.
Modified Main:
https://dl.dropboxusercontent.com/u/214507961/Panel_Top_Level_Container/Main.java
Modified GUI:
https://dl.dropboxusercontent.com/u/214507961/Panel_Top_Level_Container/GUI.java
Despite the changes, Netbeans will not allow this program to run with Java Web Start.
When I enable WebStart and Build/Clean, Netbeans creates two files:
I then clicked Build/Clean and it generated two files:
master-application.jnlp
https://dl.dropboxusercontent.com/u/214507961/Panel_Top_Level_Container/master-application.jnlp
preview-application.html
https://dl.dropboxusercontent.com/u/214507961/Panel_Top_Level_Container/preview-application.html
but no JAR file.
Still working on it. AI moved the remainder of this question to:
Why can't I get Netbeans with Java Web Start enabled to work on my executable?
At this point I'm so tired of putting up with the security hassles and see little to no way to get around certification warnings without paying. I have decided that it would probably be better to just re-write the entire client in HTML5 and javascript.
The basic concept is to build your app (GUI basicly) without using applet specific technologies (like commmunication with web page via JS etc.) and with JPanel as a top level container insteed of of JFrame (Window would be accceptable too, as JApplet extends Window). If you do so, that you will be able to deploy the same code as standalone application and via JNLP as applet.
The digital signature could not be verified by a trusted source.
This is caused by the app. being 'self signed' by a digital certificate we generate ourselves using the SDK tools. Security was increased recently so that 'self signed' apps. get that scary warning. This has been discussed extensively across SO in recent times.
Try looking at the posts under applet+security for details.
Redo the client using HTML5 and Javascript so that you don't run into any prompts or security warnings.

How to run Java Applet in browser without activating plugin?

I know this may sound like a silly question, but I was wondering if there was a way to run Java Applets on my server and embed them to a page in a way that the user would not have to "allow access" to the applet, because it wouldn't have direct connection with their computer. In other words, make an embedded java applet which wouldn't download to the client side? I understand that the lifetime of an applet is only in the web browser when a user activates a plugin and all of that.. So how can I run Java APplets on my server?
Theoretically everything is possible. Applet is a special java application that extends Applet or JApplet. Applet just extends Panel. You can simulate applet container by implementing your own dummy appet context and run applet on server side.
Now, you can capture its UI and stream it to browser using AJAX or even web sockets. You can catch mouse and keyboard events in browser, send them using ajax to server where your applet is running and emulate the same events on your applets.
But may I ask you "why?" I think these efforts can be reasonable only if you have a huge applet and do not want to re-implement it using other technologies. But IMHO it is easier to re-write your applet using ExtJs or GWT. In GWT it is probably the better way because GWT is a java that is compiled to javascript, so you will probably be able to reuse most of your code.

Java applet: run native code from browser?

Is it still possible to start a 'native' application under windows via a java applet in a browser? IE "Click here to start notepad.exe" on a web page. The most recent reference I could find for this was dated 2002. Im wondering if this model / concept is no longer supported.
Yes, but the applet has to be signed.
Signed applets will prompt the user to give them permission. Once given, the applet has the same rights as any application running on the machine, including the ability to launch native apps (or link native libraries, which I've had to do in the past).
..Is it still possible to start a 'native' application under windows via a java applet in a browser?
Sure thing. As mentioned in other replies, a signed (and trusted) applet can use Runtime.exec(String) to launch a native application.
As of Java 1.6, it becomes simpler with the implementation of Dekstop.getDesktop.open(File), which will open the selected File with whatever application the OS has registered as a consumer for that file type.
As of Sun's Plugin2 architecture (1.6.0_10+ in a Sun/Oracle JRE) offers a more generic method for an (sand-boxed) applet embedded in a web page, using the JNLP API's BasicService. Here is my demo. of the BasicService
The portable way of doing this is to create a signed Applet.

Categories

Resources