Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to run a single Java file or a Java test from the UI? #105

Closed
freewind opened this issue Dec 4, 2015 · 2 comments
Closed

Comments

@freewind
Copy link

freewind commented Dec 4, 2015

I installed the latest eclipse-che and created a simple maven java project. It contains a very simple Java application:

package maven_test;

/**
 * Hello world!
 *
 */
public class App 
{
    public static void main( String[] args )
    {
        System.out.println( "Hello World!" );
    }
}

And a test:

package maven_test;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

/**
 * Unit test for simple App.
 */
public class AppTest 
    extends TestCase
{
    /**
     * Create the test case
     *
     * @param testName name of the test case
     */
    public AppTest( String testName )
    {
        super( testName );
    }

    /**
     * @return the suite of tests being tested
     */
    public static Test suite()
    {
        return new TestSuite( AppTest.class );
    }

    /**
     * Rigourous Test :-)
     */
    public void testApp()
    {
        assertTrue( true );
    }
}

I want to run the application or the test, and chose the Java 7 runner. It works, but finally gives me an error:

[DOCKER] Removing intermediate container 75ec0758cf27
[DOCKER] Successfully built ec65a2f775dc
[INFO] Environment preparation done. Application maven-test starting up…
[STDERR] no main manifest attribute, in application.jar
[INFO] Run ended @ Fri Dec 04 06:33:55 UTC 2015
[INFO] Application maven-test has been shutdown.

How to configure che to support running a specified Java file? Is there any plugin support it?

@TylerJewell
Copy link

Hi.

Right now, you have to create an arbitrary command that runs your java
file. It's a bit of manual effort, but we will add helpers to simplify
this soon.

Here is an example:

  1. Try cloning from github http://github.com/vparfonov/executable_jar_sample
  2. In the project configuration, set this project to maven project type.
  3. You may need to go into the maven settings and specifically set it to a
    jar.
  4. Add a command, maven type, title it "build". This will do a mvn clean
    install on the project, which should build it.
  5. Add an arbitrary command, title it "run".

You will need to provide the path to the JAR file. It should be something
like, "java -jar projects/target/....". To find the specific location of
the jar, you can navigate in the terminal. The terminal is in the
operations view (upper right corner of IDE). You can navigate the folder
structure there.

In a near release, we'll have the terminal on the main screen, and we'll
also provide helpers for generating these commands that execute files &
folders in your project tree.

Tyler Jewell | CEO | tyler@​codenvy.​com | 9​78​.8​84​.53​55

On Thu, Dec 3, 2015 at 10:36 PM, freewind notifications@github.com wrote:

I installed the latest eclipse-che and created a simple maven java
project. It contains a very simple Java application:

package maven_test;
/** * Hello world! * */public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
}
}

And a test:

package maven_test;
import junit.framework.Test;import junit.framework.TestCase;import junit.framework.TestSuite;
/** * Unit test for simple App. /public class AppTest
extends TestCase
{
/
* * Create the test case * * @param testName name of the test case */
public AppTest( String testName )
{
super( testName );
}

/**     * @return the suite of tests being tested     */
public static Test suite()
{
    return new TestSuite( AppTest.class );
}

/**     * Rigourous Test :-)     */
public void testApp()
{
    assertTrue( true );
}

}

I want to run the application or the test, and chose the Java 7 runner.
It works, but finally gives me an error:

[DOCKER] Removing intermediate container 75ec0758cf27
[DOCKER] Successfully built ec65a2f775dc
[INFO] Environment preparation done. Application maven-test starting up…
[STDERR] no main manifest attribute, in application.jar
[INFO] Run ended @ Fri Dec 04 06:33:55 UTC 2015
[INFO] Application maven-test has been shutdown.

How to configure che to support running a specified Java file?


Reply to this email directly or view it on GitHub
#105.

@ghost
Copy link

ghost commented Dec 5, 2015

Hello,

Take a look - https://github.com/vparfonov/executable_jar_sample/blob/master/pom.xml#L17

We package the project into a JAR, and run java -jar application.jar command.

So, adding Main class reference to your pom.xml will fix it. It's not flexible. This is resolved in 4.0 version where you can create custom commands and pass main class as an argument in a command.

Further Maven integration is definitely on the roadmap, smth like running test for a chosen class or a method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants