如何从Netbeans内部远程服务器上部署jar文件? [英] How to Deploy a jar File on a remote server from within Netbeans?

查看:131
本文介绍了如何从Netbeans内部远程服务器上部署jar文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发了一个服务器[server.jar],它现在运行良好(在我的localhost上)。现在我想把这个server.jar放在我的远程服务器上(即:122.152.12.33)并在那里运行,所以我的客户端应用程序用这个ip替换Localhost并连接[server.jar] ...

I have developed a server [server.jar], and it is now working well (on my localhost). Now I want to "put" this server.jar on my remote server (ie: 122.152.12.33) and run it there, so My client application Replace "Localhost" with this ip and connect the [server.jar]...

我怎么能这样做?

我找到答案但不理解他们(WAR?,还有一些配置)。

I found answers but didn't understand them (WAR? , and some configurations).

我正在使用NetBeans IDE。使用netbeans部署Jar文件并转换为war。

I am using NetBeans IDE. Deployment of Jar file and converting to war using netbeans.

注意我还使用必须在服务器端上传的Mysql数据库。

Note I also use Mysql Database that I must upload it on the server side.

*更新:
另一个相关问题:

*Update: Another related Question:

如果我想要在现有网站(Wordpress发布的网站)上尝试我的server.jar,只需将我的项目添加到文件夹中,这可能会损害在线网站吗?

If I want to try my server.jar on an existing website (Wordpress released site), just by adding my project in a folder, may this harm the online site?

我可以使用php来运行Jar吗? (在线网站是链接。我想创建一个文件夹 http://akhbarna.com/MyPrject/ ...然后将Jar放在那里并通过Php运行它。
是否有可能?这可能会如何影响在线网站?

And may I use php to run the Jar? (the site that is online is Link. I want to a create a folder http://akhbarna.com/MyPrject/ ... and then put the Jar there and run it by Php. Is it possible? And how this may effect the Online site?

推荐答案

在IDE中运行距离发布和工作还有很长的路要走;-)

Running in your IDE is a long way from released and working ;-)

你的问题非常笼统,所以我的答案也很笼统,但涵盖了基本方法。

Your question is quite general, so my answer is quite general too but covers the basic approach.

关键是要考虑在全新的台式PC上运行hello world应用程序需要什么 - 你需要安装Java,创建一个包含你的应用程序的文件夹和一些运行程序的脚本然后将你的jar复制到新的台式PC并运行这些脚本。它在服务器上没有什么不同,只有你可能会使用第三方库,并且可能安装的不仅仅是Java。

The key to this is thinking what would be needed to run a hello world application on a brand new desktop PC - you'd need to install Java, create a folder to contain your application and some scripts that run the program then copy your jar to the new desktop PC and run those scripts. It's no different on the server, only you'll probably be using 3rd party libraries and will probably install more than just Java.

在我们获得更多细节之前,首先关闭,构建,发布和部署空间中的术语往往会超载。为了澄清,在下面的答案中我的意思是:

Before we get to some more details, first off, the terms in the build, release and deployment space tend to be horribly overloaded. To clarify, in the following answer I mean the following:


  • artifact - 项目生成的jar,war,zip,package等。

  • 发布 - 构建代码以创建工件并进行部署。

  • deploy - 将工件上传到存储库。

  • install - 从存储库获取工件并放置服务器以便它可以运行。

  • artifact - the jar, war, zip, package, etc produced by a project.
  • release - building your code to create an artifact and deploying it.
  • deploy - uploading an artifact to a repository.
  • install - taking an artifact from a repository and putting on a server so that it can be run.

I假设你是从头开始并且在专业环境中工作。

I'll assume you're starting from scratch and are working in a professional environment.

首先要做的是准备你的服务器。就像你使用桌面一样,如果你正在构建一个web-app,你将需要安装一些软件 - 至少Java和MySQL以及一个Servlet容器,如Tomcat。您有两个选择,要么手动执行这些安装,要么使用 Puppet 等工具自动执行这些操作 - 我建议稍后再使用设置完成后,您可以在几分钟而不是几天内构建服务器。

First thing to do is prepare your server. Like you did with your desktop, you're going to need to install some software - at a bare minimum Java and MySQL plus a Servlet container such as Tomcat if you're building a web-app. You've got two options, either you do these installations manually or use a tool like Puppet to automate them - I'd recommend the later because once setup you can build a server in minutes rather than days.

然后,您将需要某种与IDE分离的构建过程。目前流行的工具是 Maven Gradle 。构建的目的是生成一个工件,其中包含必须添加到服务器的所有内容,以便安装应用程序。在独立应用程序的情况下,这可能是一个zip,需要相当于其中的磁盘映像(jar(s),配置,启动/停止脚本)或者在web-app的情况下是战争,是Web应用程序的标准部署结构。

Then you're going to need some sort of build process that's separate from your IDE. Current popular tools for this are Maven or Gradle. The aim of the build is to produce an artifact containing everything that must be added to the server for your application to be installed. In the case of a stand-alone application this could be a zip with want amounts to a disk image in it (the jar(s), configuration, start/stop scripts) or in the case of a web-app a war, which is the standard deployment structure for a web-app.

接下来,您将需要某种类型的应用程序和数据库脚本发布过程。我最熟悉Maven能够创建罐子,战争,专有拉链或包装,并且使用它的 Release Plugin ,执行所有更新,VCS标记和部署(进入存储库,如 Nexus )需要执行发布。数据库有点棘手,通常由将应用数据库更改的DBA决定 - 通常最终会得到创建和修改数据库所需的脚本以及以正确顺序运行这些脚本的主脚本。将这些邮件放入zip中并放入存储库以便安全保存。

Next you're going to need some sort of release process for your application and database scripts. I'm most familiar with Maven that is capable of creating jars, wars, propriatary zips or packages and which, with the use of its Release Plugin, performs all the updates, VCS tagging and deployment (into a repository such as Nexus) needed to perform a release. The database is a bit more tricky and is normally dictated by the DBAs who will apply the database changes - typically you end up with the scripts needed to create and modify the database plus a master script that runs those scripts in the correct order. Pop those in a zip and into the repository for safe keeping too.

一旦发布,您需要一些方法从存储库中获取工件并将其安装到服务器。显然这可以手动完成或使用脚本完成,但我再次建议使用 Puppet ,至少对于目标服务器上的工件。使用数据库脚本,虽然这也可以自动化,但更常见的是连接到数据库并使用数据库控制台手动应用脚本(在安装新版本之前不要忘记备份代码和数据库)。

Once you've released, you need some way to take the artifacts from the repository and install them onto the server. Obviously this can be done manually or with scripts but again I'd recommend using Puppet, at least for the artifacts targetted at the server. With the database scripts, while this can be automated too, it's more common to connect to the database and apply the scripts manually using a database console (don't forget to take backup of both code and database prior to installing a new version).

最后你可以启动你的系统。

Finally you can start your system.

这篇关于如何从Netbeans内部远程服务器上部署jar文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆