user3359964
user3359964

Reputation: 345

How to run spring boot application in windows which is developed in eclipse in Ubuntu os?

I'm new to spring boot. I have written code to display "hello world". HelloWorld1Application.java: package com.example.demo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class HelloWorld1Application {

public static void main(String[] args) {
    SpringApplication.run(HelloWorld1Application.class, args);
}
}

AppConfiguration.java :

package com.example.demo;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class AppConfiguration {

@RequestMapping("/hello")
public String hello() {
    return "Hello World";
}
}

It runs fine in Eclipse ide. I have tried it in terminal n got proper output(java -jar target/HelloWorld1-0.0.1-SNAPSHOT.jar). Now I want to run this program in windows. How can i do that? Where can i find the bytecode of this application? How to execute it in command prompt of windows?

Upvotes: 1

Views: 8326

Answers (3)

Midhun Mohan
Midhun Mohan

Reputation: 689

  1. Install JDK and maven(set Java Binaries to your system environment)
  2. on the project directory try mvn spring-boot:run

Upvotes: 2

alok.s.jadhav
alok.s.jadhav

Reputation: 71

You also need to set JAVA in your PATH environment variable. Add location till bin in your path variable

C:>path
C:>PATH=C:\Program Files\Java\jdk1.8.0_171\bin
C:>java -version
java version "1.8.0_171"
Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)

Upvotes: 1

Smile
Smile

Reputation: 4088

  1. Copy HelloWorld1-0.0.1-SNAPSHOT.jar to windows
  2. Execute java -jar HelloWorld1-0.0.1-SNAPSHOT.jar in command prompt

Note: make sure you have JRE installed on windows machine.

Upvotes: 3

Related Questions