简体   繁体   English

在服务器上运行Java应用程序

[英]Running Java application on server

I have access to a server using SSH. 我可以使用SSH访问服务器。 I need to run a stand-alone Java application on it to access a MySQL server installed there. 我需要在其上运行一个独立的Java应用程序来访问安装在那里的MySQL服务器。 How do I go about in doing this? 我该怎么做呢?

Assuming it is a linux machine, you have to connect to by using SSH it and use scp command to upload the files and deploy it... than you have to run the JAR you deployed: 假设它是一台linux机器,你必须使用SSH连接它并使用scp命令上传文件并进行部署...而不是你必须运行你部署的JAR:

java -jar /path/to/file.jar

Or, provide more details please 或者,请提供更多详细信息

Assuming you have the requirement to copy the JAR file on the *nix box and then run it(and not connect a Java process to it remotely) 假设您需要在* nix框中复制JAR文件然后运行它(而不是远程连接Java进程)

  • Create a standalone JAR which contains all the dependencies required to run the application 创建一个独立的JAR,其中包含运行应用程序所需的所有依赖项
  • Make sure you have Java installed on that machine 确保在该计算机上安装了Java
  • Assuming it's a *nix box, set the $PATH environment variable to point to $JAVA_HOME/bin 假设它是一个* nix框,将$ PATH环境变量设置为指向$ JAVA_HOME / bin
  • Log on to that box using a SSH client. 使用SSH客户端登录该框。 Any decent SSH client also comes with a FTP plugin which allows you to transfer files between your local box and the server 任何体面的SSH客户端都附带一个FTP插件,允许您在本地盒子和服务器之间传输文件
  • Copy the JAR to the appropriate directory and run it using the java -jar your.jar command 将JAR复制到相应的目录并使用java -jar your.jar命令运行它

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM