0

I wrote a simple terminal program in IntelliJ. I'm using Gradle (and I actually don't know how to use it).

I can run the program inside IntelliJ IDE, everything works fine.

Now I want to copy it to another machine: Debian with Java(TM) SE Runtime Environment (build 1.8.0_45-b14).

My program uses an external library (jaunt0.9.9.9.jar).

I have added this libary in "Project Structure -> Dependencies -> Add".

I guess I have to make a -.jar file, but when I run "MyProjectName [jar]" task - I'm getting an error like this:

src\main\java\Hello\MyProjectName.java:3: error: package com.jaunt does not exist import com.jaunt.*;

Am I doing something wrong?

Nathalie
  • 192
  • 2
  • 17
Kamil
  • 13,363
  • 24
  • 88
  • 183

2 Answers2

2

If you use the 'application' plugin in Gradle it will do everything you need to package up the application and deploy it to another machine.

In your build.gradle add this plugin:

apply plugin: 'application'

Specify the main class to run

mainClassName = "org.gradle.sample.Main"

Then run the task

$ gradle distZip

This will create a zip file you can copy to a machine which includes a shell script for launching.

For more information see the Gradle page on the application plugin

tddmonkey
  • 20,798
  • 10
  • 58
  • 67
2

I think you are missing a dependency declaration in your project's build.gradle file. You added the correct dependency manually in IntelliJ, but this does not automatically add the dependency declaration to the build file.

In build.gradle try adding something like this:

dependencies {
    compile files('relative_path_to_jar/jaunt0.9.9.9.jar')
}

Also, see answers to this similar question.

Community
  • 1
  • 1
Doron Gold
  • 3,664
  • 4
  • 32
  • 44