0

I built a java program that consists of 2 files. The one that contains the main is SnortMonitor.java and it uses Database.java to connect to the database and run a query. I migrated it from my windows machine to the linux machine where it needs to be. I am able to compile it and run it just fine on both machines.

My ultimate goal, which is my next step, is finding a way to make this into an executable with will constantly run on this linux machine. The program is designed to scan each record of a database and send certain information to another machine, I need it to run constantly so that it is constantly sending this information to this other machine, or something like every 3-5 seconds.

One Footnote: For some reason that is beyond my knowledge, I ended up with SnortMonitor.java, Database.java, SnortMonitor.class and Database.class once I finished compiling and running on linux, I'm not sure if this makes a difference, I'm very new to linux.

1
  • the .class files are the output of the java compiler. So if you feed in a .java source file, you'll get a corresponding .class file which is what the Java Virtual Machine (JVM) executes, so that's perfectly normal (and to be expected after compilation) Commented Jul 13, 2012 at 1:36

1 Answer 1

3

You have two options:

  1. Create a start-up script, such as a .sh bash script for example, that launches your java application. See Tomcat startup script for an example.
  2. Use GCJ to compile it to machine code, but your application loses portability.

Personally I prefer the first option, but choose what is right for you.

Sign up to request clarification or add additional context in comments.

3 Comments

Like I previously stated, I'm new to java, but I think I know what you mean by using the first method. So this script, which I will name "TESTRUN", will contain a loop that complies and then runs my program constantly. Is this correct?
+1 for shell script possibility #1. You might also want to write a corresponding dos batch script (.bat file) and then folks could use that to run the program on windows too if needed.
You don't need compile it on every run. Yon can compile it once and then run the "compilation result" (the .class that you say) every time. You need to recompile only if you change your source files (.java).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.