简体   繁体   English

如何在没有eclipse的服务器上运行eclipse之外的java程序

[英]how to run java program outside eclipse on a server that doesn't have eclipse

我在eclipse中写了一个包含很多类的java程序,这是我第一次在java和eclipse中编写代码,现在我需要在没有eclipse的服务器上运行这段代码。

Compiling & Running a Simple Program . 编译和运行一个简单的程序

This is your best starting point. 这是你最好的起点。

Use "File -> Export -> JAR file" wizard to create a .jar file contained your compiled classes. 使用“文件 - >导出 - > JAR文件”向导创建包含已编译类的.jar文件。 You can then copy this .jar file to your server and use java.exe to run it. 然后,您可以将此.jar文件复制到您的服务器并使用java.exe来运行它。 Use "java -help" from a command line to get instructions. 从命令行使用“java -help”获取指令。

Please go through link provided by Andrew 请浏览安德鲁提供的链接

Eclipse is an IDE , it facilitates development but not actually required to run your code, if you want to run your java file in a server somewhere, make sure you have JRE installed in your "server" and in your Path, then run following command in your server's shell environment Eclipse是一个IDE,它促进了开发,但实际上并不需要运行代码,如果你想在某个服务器上运行你的java文件,确保在你的“服务器”和你的Path中安装了JRE,然后运行以下命令在服务器的shell环境中

javac filename.java

above command will generate a .class file in the same directory, which is actual file that can be executed using following command, 上面的命令会在同一目录下生成一个.class文件,该文件是可以使用以下命令执行的实际文件,

java filename

assuming your code is inside a file called filename.java 假设您的代码位于名为filename.java的文件中

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

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