Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
CarrKnight
May 24, 2013
I know this sounds weird to say in 2014, but are Java applets dead?

I have a very simple JavaFX application. Small time, academic stuff. I'd like to place a weblaunch/jnlp link on my blog so that my professors can open it.
Unfortunately java security always shuts down the application.
Basically since java7u51 all web applets, even when running on sandbox mode, need to be signed. And not just self-signed, but signed by a certificate authority. That's not the kind of thing a graduate student like me can afford.

Does that mean that only businesses that can afford it now are allowed to use applet/weblaunch? That's so incredibly frustrating.

Adbot
ADBOT LOVES YOU

CarrKnight
May 24, 2013

rhag posted:

By default that is true, self-signed applets won't run anymore. But, if your users are willing, they can tell java that they trust site http://yourblog.com and then they will be able to run your self signed java application from jnlp.
They can do that from the Java Control Panel in the Security tab.

Yeah, that's true. But it's very much of a drag. I wouldn't bother with it if I stumbled upon my blog. Which is sad, really.

CarrKnight
May 24, 2013
Hope this is the right thread to ask this.

So I code agent-based models. Which you can just imagine being complicated 2d games.
I code them in Java I like structured object oriented programming.

My issue is with deployment.
I want other people to use my models. To "play" my games.
Few years ago all I had to do was to place a java applet somewhere and people could just use my model straight from a web-page.
Now applets only work if I pay hundreds of dollars to Verisign to sign them.

I'd like another way to code the gui so that anybody can use my model just by connecting to a web-page hosting it. The GUI can be any language. I am willing to learn. The "backend" model has to stay Java though.
I am really confused. Is there any technology that allows this? Mind you: these aren't web-apps. There is no server/communication involved. You download your 10mb model and you are good to go.

Suggestions on the tech to use to code the gui?

CarrKnight
May 24, 2013

quote:

With newer version of the JRE installed, they had to specifically say they trust the server in the Control Panel applet
Yes exactly. I'd need to tell my audience to go to their settings, lower them and so on. They aren't going to do it.
It's a pain. They'll just go somewhere else.

quote:

If you're ok with people downloading the app, why not just make a jar, or whatever the new-fangled web-start stuff is called nowadays?
Web-start requires signature or lowered security settings or both.
Download and run is my current modus operandi, but i really wish they could just run from the web.

quote:

If you wanna change the UI, in HTML 5 you can do quite nifty things with WebGL and java script: https://www.unrealengine.com/html5 .
This is what I hear, but how do I use an HTML5/javascript/webgl GUI over a java program? Is there a set of libraries?

CarrKnight
May 24, 2013
I'd imagine that killing all sorts of reactivity, right?
Is there a code example of a java-backed html5 2d game?

CarrKnight
May 24, 2013
First of all, thank you for all the answers.

quote:

Is your audience likely to even have the JRE installed and enabled? I mean I'm someone who codes in Java and if I see a webpage trying to run a Java applet, I usually say 'gently caress this poo poo' and hit that back button. Not saying I'm a representative sample or anything, and you know your audience, but if you're looking for ease of use I'd imagine you want something that just runs 'natively' in the browser
Exactly!

Okay, to clarify what I need. Imagine a very, very lovely sim-city. Take model-view-controller abstraction.

The model is the citizens, the markets, the rules of trading, the geography. All that stuff. It has to be in Java. This is because the end goal of these models is peer-review. And since others in my field code in Java, I need to do the same. I show up with go or dart and people just don't know what they are looking at.

The view and the controller, I'd like to be native in the browser. This makes for much easier prototyping and I can let my audience play with the model before it is complete and before they need to plunge into the source code.
I can code this in any language i see fit. Peers don't care.

Now, what I don't understand is, if I learn HTML5 or Javascript or whatever do I need to implement a server-client interaction? If so, what machine is actually running the model (the city simulation)?
That's what I liked about applets. It would just work out of the box.

CarrKnight
May 24, 2013

Gul Banana posted:

In general there's no way to do general-purpose execution on the web client. Only specific exemptions exist: chrome's nacl, java applets before the security problems, flash until it dies... Unless you can fit into one of those holes, it's javascript only.

Got it, thanks!

CarrKnight
May 24, 2013

evilentity posted:

If you want to do the codes in java for 2d game, and make it run in modern browser, use libgdx. With very little work you can compile it js and run in a browser. No need to implement client-server stuff. But you would need to rewrite a bunch of stuff, mostly the rendering/gui. Heres an old demo of my android game running in a browser, no plugins or anything required

That looks really cool. Let me take a look. You were very kind. Thanks.

CarrKnight
May 24, 2013
I want to know, is google GWT kind of like libgdx?
Libgdx is cool, great. I like the easy life-cycle. But I need boring ui. With buttons and charts. Kind of like the GWT widgets! But is gwt just a client gui with the java part running on a server? Or is it like libgdx where the whole java is magically turned into javascript and run in browser?

CarrKnight
May 24, 2013

evilentity posted:

You can make boring gui in libgdx just fine. spine 2d is made in libgdx.

That looks fantastic. But it is proprietary.
Is there anything similar that is open-source enough for me to peek?

CarrKnight
May 24, 2013

quote:

My problem is that this loop never finishes even if the button is clicked (a print statement in the actionListener shows it works) and start is set to true unless I either print something to the terminal or use Thread.sleep(1) (or any number) within the while loop
For these things you really ought to use a semaphore.
But i am curious, what happens in the //wait part?

CarrKnight
May 24, 2013

Loezi posted:

Unless you have been outright told to save the balance as a double stop right here and convert to int of cents (or local variant). Doubles are unable to represent all the required values and you'll sooner or later run into bugs with account balances like 100.00000001 and two "same" balances being not equal to each other.

A quick example of the kinds of problems you'll have with double balances is this:
code:
System.out.println(1.03 - .42);
// prints 0.6100000000000001

BigDecimal could help but it's cumbersome, Java 9 should come with a money API too.

CarrKnight
May 24, 2013
And I imagine adding and subtracting monetary values will be the most painful experience in the universe (see big decimals).

After trying my hand coding Dart I miss simple operator overload in Java.

CarrKnight
May 24, 2013

quote:

I can see that, but I've recently poked my head into Scala, and it is not fun trying to figure out what in the hell the ::% operator is supposed to signify when reading someone else's code.
Oh yes, those are some weird operators.
Dart pairs it down to the usuals +,-,[],>, you know, what you'd call an operator.


Now, I personally like Java's verbosity a lot. Except when dealing with things where the operator is obvious.
If I have to do something like this:
Big Decimal("5.1").plus(new BigDecimal(".23")).multiplyBy(new BigDecimal(".11"));
I am wasting my time.

CarrKnight fucked around with this message at 09:52 on Dec 9, 2014

CarrKnight
May 24, 2013
On the topic, does anybody here unit tests swing? I'd like to know what program you use, but also how to structure gui unit tests (i find it so hard to isolate the gui)

CarrKnight
May 24, 2013

quote:

so you're likely to end up spending a lot of time rewriting the tests.
I know for a fact that's true

quote:

Try to get as much of your logic out of the GUI as you can (ideally everything not specific to the construction and arrangement of your Swing components
You are right, unfortunately in my field we tend to use old libraries that make this hard. But yeah, I try my best.

CarrKnight
May 24, 2013

JimboMaloi posted:

That's super unfortunate. Are you ending up with a bunch anonymous SwingWorkers inside your Swing classes? Are you running your business logic on the EDT?

I am not running the business logic on the EDT, but that might be maybe the only good thing I can say about the libraries I use.

CarrKnight
May 24, 2013
So this is a general question, but I am implementing it in Java so here it is.

I have a somewhat hierarchical structure in my code, something like this:
code:
class Agent{
  
final private Strategy1 strategy;

final private Strategy2 another;

final private int field;
...
Then I have a big constructor that receives all the strategies and fields needed when instantiating the agent:
code:
public Agent(Strategy1 strategy,Strategy2 another, int field)
Now, I need to instantiate this agent from a JSON object
code:
{
  "agent": {
    "strategy1": {
      "type": "nameOfImplementation",
      "constructorParameter1": "...."
    },
    "strategy2": {
      "type": "nameOfImplementation2",
      "constructorParameter1": "...."
    },
    "field": 42
  }
}
What would be the best way to do this? Notice that the various implementations of Strategy1 (and 2) have constructors with different parameters (and potentially sub-strategies).
My current approach is to use Map<String,Factory<Strategy1>> or whatever, but I am not sure that's the best way to go about it.

CarrKnight
May 24, 2013

Jabor posted:

It looks a lot like you're trying to solve the Dependency Injection problem. I'd recommend taking a look at some of the mature DI frameworks around and seeing if any of them is suitable for your needs.

Yes! I think so. I only encountered the definition of DI in testing books but it's correct.

Now my main problem is that I work with a team of academicians and to be honest I can't expect them to go through Guice or Spring. I had a small lecture on what @Nullable and @NonNull mean and if I start adding more weird stuff I make the code illegible for anyone but me.

Is there a framework that is easily readable?
Need to look at Jackson I guess.

CarrKnight
May 24, 2013
Awesome. Is there a name for this kind of pattern?


That's pretty much what I do except I make it into a separate factory class, well really Function<Json,Strategy> since I might need to modify the parameters through GUI after they are read but before the strategies are created.

CarrKnight
May 24, 2013
So I really need a place and method to store large amounts of transient and temporary data.

Best summary I can give, imagine a videogame like Sims. Each sim does stuff and it creates a record of everything it does. While it was still a simple game I just stored every record in a LinkedList. Each Sim had its own LinkedList with its own records in it. Sometimes the sim needs to take these records and analyze them and sometimes I need them for debugging.

Now, it worked when everything was simple and quiet but now there are gazillions of records being created and they quickly overwhelm the memory so I need some framework/idea on how to store this information on disk in a way that makes sense and it's easy to retrieve while the game is running but there is no need for permanence (no saved games or anything like that)

Is SQL still the way to go?

Adbot
ADBOT LOVES YOU

CarrKnight
May 24, 2013
JCommander is another library that helps with main arguments. This is an example of how to code the help case.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply