TransWikia.com

How to run a java program with an external jar + a command line argument on a Linux server/terminal?

Stack Overflow Asked by Cans on February 23, 2021

For months, I have been trying to figure out how to run my java code in my university’s servers. In my projects, I either create a mathematical model or develop a heuristic algorithm. The example given below is for a heuristic algorithm. I use Eclipse to run my program. In the server, I have to use command line.

In the picture below, you can see all my classes. The main class is MainNewConstructionALNS.java which uses the remaining classes (Node, Pair, Solution, Vehicle). I need to have external cplex.jar due to some functions I use it. And, Param.txt is an argument that holds some parameters for the program (such as the number of nodes x-y coordinates, etc.) – Note: I put all the files under the same folder to refer to them easily. Please inform me if it is wrong.

enter image description here

In this image below, I first run javac and then java (as suggested by other posts). If you see anything wrong, please let me know. After the javac command, it creates class files (see the last picture). However, my java command doesn’t work! I tried both "java MainNewConstructionALNS.java < Param.txt" and "java MainNewConstructionALNS.class < Param.txt" – but the same error.

Could you please help me with that? I spent months on this. Every time, I quit because I couldn’t figure it out and couldn’t find proper help.

I hope you can enlighten me! I appreciate all the help in advance.

Note: I am not familiar with Linux or command line codes.

enter image description here

enter image description here

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP