Running Java Program in Eclipse multiple times [closed] - java

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I wrote a Java program in Eclipse that uses Processing IDE libraries, and it works just fine. This program gets some data from a .csv file and assign those values to the variables inside the program.
I want to make this program run multiple times automatically and sequentially, and before each run I want to modify some of the data from the .csv file so that I can get different outputs at each time.
I've been thinking about this for a long time and couldn't come up with any answer myself. Any help will be appreciated.
Thanks,
Mert

One of the simplest way of I can think of is creating infinite for loop, but this is only on the assumption that your question is based on some sort of assignment,
for(;;){
// read the folder path
File folder = new File("your folder path");
if(folder.listFiles().length > 0){
//read files - your csv file
//process files - capture any values
//delete file - delete the file
}
}
Now you can change the csv file manually, put it in this folder, let the program read it and once it is deleted you will understand it is processed and you can add new file/s.
Also it is not clear that how long due to want the program to run, accordingly you have to take care releasing File resources in your program so they are available for garbage collection.
Hope this helps!!

Related

Is it possible run files in JAR file using Java? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I want add a file into the jar package but this is a separate file from the java program, can I run it and if I can run it, how can I run it? Can you recomment anything?
Thanks.
Not possible; java doesn't run arbitrary executables; your OS does. Java ask your OS to run an executable, but OSes generally do not have the ability to run executables from within zip files. Let alone jmod files.
If your java application can read and process the data itself (example: Render a swing JLabel object with some PNG as its image), then you can to this:
YourClass.class.getResource("open_url.png")
Will get you an inputstream for the stated file, as long as that file is in the same place that YourClass.class is - even if it is in a jar file or jmod file.
However, if you have an .exe, you'd have to extract the executable, save it to a tmp dir, and then ask the OS to run that file. Saving executables to temp dirs is a little tricky (if it's a global temp dir, some other user could overwrite your executable in the middle, and thus run its code in your process, you see how that's security-wise quite a big issue). But, you can do it. Note that this makes your app not platform independent anymore, of course.

How to create, access and edit csv documents on internet using java [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I'm creating a game in java and I want to store the scores on a csv file on the internet so different people who download the game and can compete for a high score.
How can I:
create a csv file and give it a url
make the csv file editable only through my program
access data from that csv file given its url
edit that csv file given its url
thanks!
Edit: Sorry I don't have code to post as I don't even know where to start. I tried looking it up but only find things relating to files that have already been downloaded
run a server (probably in java) on a computer that is always on, and have the client (the game) connect to it via a socket. Use something like freedns or noip to get the URL.
have the client report its score to the server, and the server will write it to a csv file.
have the client request scores from the server
this is solved by 2
sign up for freeDNS here
use this tutorial for sockets: youtube.com
if you don't have a computer that is always on, try using amazon AWS free
This is probably a bit more complicated than what you wanted, but it's the only way I've heard of.

Eclipse - How do i add a save/load feature to my .jar game? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I am creating a Choose your own adventure in Eclipse Mars 2 and I would like to implement a save feature so i can save the game with a button and re load where i was with another. I am fairly new to programming and don't know how to go about this.
A common way of doing this is to save the game state to a file at location X on the user's filesystem, and to load the game by reading the file (if any) at location X. There are several main challenges here:
The user might not appreciate your game writing files. However, file-writing happens all the time by various applications to store settings and other saved information.
If the user deletes the file, their save is also lost.
You'll have to figure out how to serialize and deserialize your game state to a file.
Users now have a way of cheating by modifying the file if they can reverse-engineer your (de)serialization process.

File isn't being written to (FileWriter) [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
So I have this text file called 'arrlog.txt' that I want time data written to.
I have defined a button called 'btnArr' and a time text field called 'etArr'. When I open this in the emulator, it literally doesn't do anything. It doesnt read to the file. It doesn't shout and scream with an error (IOException), it just closes and does nothing. Rather strange as I cant find a place in my program for this application to simply just close.
I think it may not be initialising something correctly, the file path is correct and so the FileWriter should either run the catch or it should find it and write the numbers into the file.
First, when asking for help with programming problems, please post the source code as text, not as a screenshot.
the file path is correct
No, it is not. Android does not have a C: drive. Presumably, your development machine is Windows, and that machine has a C: drive. But neither your Android device nor your Android emulator is Windows.
You are welcome to write your data to internal storage or external storage, though.

How do I pass variable(s) from a VB.NET application to an already running Java application on the same computer? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I hope this doesn't sound silly. I've looked it up but can't find anything.
Let's use this example to keep from being too general. In my VB.NET application, I want to do this:
Dim ASDF As String = "This is a string."
Dim UIOP As Integer = 54
From here, I want to send the values of these variables to a Java application that is already running locally on my computer - I don't want the program to start the application because it is already running. What would be the simplest way to achieve this? Thanks for your help!
I had a similar problem once which involved passing information from a Python program to a C++ application which was already running, same as in your case.
The most reliable solution I could find was to simply have the first program create a text file with the relevant info, and then have the second program read and destroy the file. This solution works really well if you only have to pass information between programs a few times, not continuously.
A more structured way of doing the same thing, instead of using a text file, would be to use an XML file. Both Java and VB.NET support XML data parsing, VB.NET with XmlTextReader and Java with Document Object Model. Using xml will allow you to have a hierarchical structure for your data.

Categories