Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
**.DS_Store
target
20 changes: 20 additions & 0 deletions Biggest3
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <stdio.h>
void big3() {
double n1, n2, n3;
printf("Enter three different numbers: ");
scanf("%lf %lf %lf", &n1, &n2, &n3);

// if n1 is greater than both n2 and n3, n1 is the largest
if (n1 >= n2 && n1 >= n3)
printf("%.2f is the largest number.", n1);

// if n2 is greater than both n1 and n3, n2 is the largest
if (n2 >= n1 && n2 >= n3)
printf("%.2f is the largest number.", n2);

// if n3 is greater than both n1 and n2, n3 is the largest
if (n3 >= n1 && n3 >= n2)
printf("%.2f is the largest number.", n3);

//return 0;
}
19 changes: 19 additions & 0 deletions Fact_n
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include <stdio.h>
void fact() {
int n, i;
unsigned long long fact = 1;
printf("\n\nEnter an integer: ");
scanf("%d", &n);

// shows error if the user enters a negative integer
if (n < 0)
printf("Error! Factorial of a negative number doesn't exist.");
else {
for (i = 1; i <= n; ++i) {
fact *= i;
}
printf("Factorial of %d = %llu\n", n, fact);
}

//return 0;
}
5 changes: 5 additions & 0 deletions Main
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include <stdio.h>
void main() {
big3();
fact();
}
8 changes: 8 additions & 0 deletions Make
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
ABC.exe:main.o biggest3.o factorial.o
gcc -o ABC.exe main.o biggest3.o factorial.o
main.o:main.c
gcc -c main.c
biggest3.o:biggest3.c
gcc -c biggest3.c
factorial.o:factorial.c
gcc -c factorial.c
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: java $JAVA_OPTS -jar target/dependency/webapp-runner.jar --port $PORT target/*.war
55 changes: 54 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,54 @@
# JavaRepo
# java-tomcat-maven-example

This is an example ready-to-deploy java web application built for Tomcat using Maven and webapp-runner.

## Running Locally

(need maven and java installed)

```
mvn package
java -jar target/dependency/webapp-runner.jar target/*.war
```

The application will be available on `http://localhost:8080`.

## How This Was Built

1. Generate the project using a Maven archetype:

```
mvn archetype:generate -DarchetypeArtifactId=maven-archetype-webapp
```

2. Add the webapp-runner plugin into the `pom.xml`:

```
<build>
<!-- ... -->
<plugins>
<!-- ... -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals><goal>copy</goal></goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.github.jsimone</groupId>
<artifactId>webapp-runner</artifactId>
<version>8.5.11.3</version>
<destFileName>webapp-runner.jar</destFileName>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
```
44 changes: 44 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>java-tomcat-maven-example</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>hello Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>java-tomcat-maven-example</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals><goal>copy</goal></goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.github.jsimone</groupId>
<artifactId>webapp-runner</artifactId>
<version>8.5.11.3</version>
<destFileName>webapp-runner.jar</destFileName>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>