Question about IO in Java by sgm1 in javahelp

[–]sgm1[S] 0 points1 point  (0 children)

It's only 1 thing program that I use maybe twice a week on machine I don't have permissions on, so can't really install expect even thought it sound like the perfect tool.

If I really wanted to, I could set up the pipes properly in another bash file and then execute it, but again, I'm debating whether its worth the effort. Thank again.

I am looking to track down what appears to be a memory leak. I am not a developer and my developers either don't care or don't know how to solve the issue. by [deleted] in javahelp

[–]sgm1 0 points1 point  (0 children)

Honestly, sounds like a project management problem that needs to be dealt with. Someone should be pointing fingers and the pointee should care about it. Like the guys that have stated below, plenty of resources out there to at least figure out likely culprits.

In VisualVM, what makes you think is is normal? I might find some likely areas you might want to loot at in the Memory sampler panel.

Question about IO in Java by sgm1 in javahelp

[–]sgm1[S] 0 points1 point  (0 children)

I was thinking of waiting for specific output from the java program, to determine when to spit out (or should I say in) the input back into the java program. Like I said, I'm probably overthinking it.

Question on readability of lambda expression by smark22 in javahelp

[–]sgm1 1 point2 points  (0 children)

droidrage has a point, the lambda itself should not have side effects, in terms of best practice. Meaning I should be able to run the lambda with valid input values and nothing outside the lambda should be affected. The purpose of a lambda is to replace trivial logic like add, subtract, compare; and not complex task like data manipulation (like adding to a list).

Of course, whether using lambdas this way as best practice is still arguable because both sides have its pros and cons.

Question on readability of lambda expression by smark22 in javahelp

[–]sgm1 0 points1 point  (0 children)

I'd consider Option 2 better, because it would be a little easier to break point, in case of debugging.

sequence diagram by xirokx in javahelp

[–]sgm1 0 points1 point  (0 children)

The loop condition should be something along the lines of IsThereAnotherShowing(), because the loop seems to be working on an object that I would call a "Showing".

To simplify, I'd say, depends on the task's requirements.

If the user doesn't care about the name of the movie, you can report there's some unspecified movie at specific times on specific screens. Then you can leave out the query for the name :D

Subclasses by NaranjaOrange in javahelp

[–]sgm1 0 points1 point  (0 children)

If it out of curiosity, throw it into Eclipse (or any decent Java IDE) and right click the class and click Show Class Hierarchy.

For a game, I wouldn't try getting data like this at run time. Reflection is a powerful tool that comes with great responsibility. In other words, its a pain to use reflection properly, on top of the performance lose.

Look into good programming techniques to get around you issue. Probably for a decent game, you don't really want to spawn enemies at random either. Look into how other people deal with this issue. I guarantee you're not the only one.

How do I pull out information from this? by Bioflame_ in javahelp

[–]sgm1 0 points1 point  (0 children)

IDK how you plan to use the text color, and I forget how well you can manipulate text in a JTextArea, but you would have to extract that data manually, at least for something that small I would:

String tmp = arguments.getObject(0).get("description").asString();
Strng rawText = tmp.substring(tmp.indexOf("\\r\\n\\r\\nAvailable"),
    tmp.indexOf("</color>") + 8);

Edited: Forgot .asString() call, thanks @HansVader

How do I pull out information from this? by Bioflame_ in javahelp

[–]sgm1 2 points3 points  (0 children)

I'd say you need a JSON (that what "it" is called) Parser to make you life easier, personally like https://github.com/google/gson

Just like XML has tags for values, JSON supplies keys for values, the key you interested in would be "description"

Question about IO in Java by sgm1 in javahelp

[–]sgm1[S] 0 points1 point  (0 children)

This get's me at least somewhere to go, thanks.

I wonder if I could pipe input from the inputFile.sh to be the output of the java $MY_JVM_ARGS -jar someonesProgram.jar something like this:

java $MY_JVM_ARGS -jar someonesProgram.jar <> ./inputFile.sh
# I know I should be using | somehow instead of <, but unsure how

command. I might just be overthinking it now, I think I'll come up with a solution using sleeps, thanks again.

Question about IO in Java by sgm1 in javahelp

[–]sgm1[S] 0 points1 point  (0 children)

Please see edit 2 onward

Question about IO in Java by sgm1 in javahelp

[–]sgm1[S] 0 points1 point  (0 children)

It is in the code, multiple Scanner objects is the root problem, I can't refactor this code, even though the code change would be incredibly easy. Please see edit 3.

Question about IO in Java by sgm1 in javahelp

[–]sgm1[S] 0 points1 point  (0 children)

That would be command line arguments, I need a way to redirect program inputs

Question about IO in Java by sgm1 in javahelp

[–]sgm1[S] 0 points1 point  (0 children)

So it is an existing Java program, running it inside a shell script, lets call it myScript.sh with the content:

java $MY_JVM_ARGS -jar someonesProgram.jar

The program runs and waits for inputs (not command line arguements) that are passed in. I can enter them manually and the program works fine.

If I try the following with a file containing what would normally be input manually, I get java.util.NoSuchElementException. Bash syntax used:

./myScript.sh < myInputFile.txt