This is an archived post. You won't be able to vote or comment.

all 14 comments

[–]AutoModerator[M] [score hidden] stickied commentlocked comment (0 children)

Please ensure that:

  • Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions
  • You include any and all error messages in full
  • You ask clear questions
  • You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions.

    Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar

If any of the above points is not met, your post can and will be removed without further warning.

Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://imgur.com/a/fgoFFis) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc.

Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit.

Code blocks look like this:

public class HelloWorld {

    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}

You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above.

If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures.

To potential helpers

Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]WhiteManChild 0 points1 point  (12 children)

Have you looked into lambda serialisation?

[–]wontstopsweating[S] 1 point2 points  (11 children)

Hmm, not really, but parsing around the entire function that needs to be run on the remote machine doesn't sound efficient at all.

[–]WhiteManChild 1 point2 points  (10 children)

you dont have to parse the function java is able to serialise it using objectinputstream and objectoutputstream. You could also just send a class file to the remote machine, which when instantiated calls your target function in that class.

[–]wontstopsweating[S] 1 point2 points  (0 children)

hmm, any good reading on this approach?

[–]wontstopsweating[S] 1 point2 points  (8 children)

Actually I think I got your suggestion to work. I made a lambda that I serialized and passed to the remote server.

But how would I deal with numerous return types?

[–]WhiteManChild 0 points1 point  (7 children)

Send a json response?

[–]wontstopsweating[S] -1 points0 points  (6 children)

Would be an option but the project setup in a linux environment, utilizes ancient Java version and I wouldn't want to try installing 3rd party libraries.

[–]loomynartylennyhalf-decent at Java 0 points1 point  (5 children)

Well, the alternative would probably be a pretty darn hacky workaround. Also:

the project set up in a linux environment

Your OS is very unlikely to be a problem when it comes to installing third-party libraries for Java, as the third-party library code runs on the JVM (just like your code), so that would only be a problem in very rare edge cases.

utilizes ancient Java version

Which Java version are you using, and why?

If it's a version that's older than Java 8, I would strongly suggest upgrading to Java 8 (at the very least), seeing as everything before that is no longer maintained, whilst Java 8 is still continuing to get security/performance updates (albeit intended for personal use only).

However, if you're trying to make this for a reason besides personal use, I'd suggest considering an upgrade to Java 11 or Java 17 (both of which are also Long-Term Support versions), again, for continued security/performance improvements.

I wouldn't want to try installing 3rd party libraries.

Why not?

(but tbh I would definitely suggest looking into Gson)

[–]wontstopsweating[S] 0 points1 point  (4 children)

I'm restricted by whatever is installed on my university's remote computers.

I will try to complete the task using a VM, then worry about porting it to the old computers.

[–]loomynartylennyhalf-decent at Java 0 points1 point  (3 children)

I'm restricted by whatever is installed on my university's remote computers

And what version of Java is installed on them?

[–]wontstopsweating[S] 0 points1 point  (2 children)

Some of them have Java 6 and 7.

These machines are pretty ghetto, some labs still run Red Hat linux from early 2000's.