0

I want to start an existing Java-program. I use Ubuntu 18.04, VS Code and installed openjdk-11-jdk. I installed the java extension pack as adviced on this site : https://code.visualstudio.com/docs/languages/java.

I created a new project and substituted the created src folder by the src folder of the program I want to run. I also created a workspace, containing the whole project. The project contains several possible entry points. I chose one and clicked on the displayed "play"-button. It starts to compile but fails with the message: "java.lang.NoClassDefFoundError: GameBoard". GameBoard is a class that is indeed needed and located in the upper folder but still inside the src folder of the whole project. It also shows a warning massage that ".classpath" was incomplete. But the file exists and contains a link to the src folder as it should be, I suppose. One time it also displayed the error message, that a function in the main-class was twice defined which is clearly not the case. There are instructions how to start said program and I think I followed them: https://github.com/WolfgangKonen/GBG/wiki/Install-and-Configure They are for eclipse thow but that shouldn't really matter, I suppose.

So could somebody tell me, what I am doing wrong? I'm a bit out of ideas. I really just want to start the program and quickly test it and nothing more. Command line would be perfectly ok, as well. I don't have much experience with setting up java projects in general.

EDIT: I created the project within VS Code. The created project is called .project and seems to be an eclipse-project-file. This was the only way I found to create a project from within the IDE. Maven seems to be a command line tool. The parameter structure seems a bit complex at first glance, but I might have a look at this tomorrow, if there is no quicker solution.

Those are the contents of the .project file and the .classpath file respectively:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<projectDescription>
  <name>GBG</name>
  <comment/>
  <projects>
    </projects>
  <buildSpec>
    <buildCommand>
      <name>org.eclipse.jdt.core.javabuilder</name>
      <arguments>
            </arguments>
    </buildCommand>
  </buildSpec>
  <natures>
    <nature>org.eclipse.jdt.core.javanature</nature>
  </natures>
</projectDescription>

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-10"/>
    <classpathentry kind="src" path="src"/>
    <classpathentry kind="output" path="bin"/>
</classpath>
  • could you include the POM file please – rLevv Dec 14 '18 at 01:42
  • also have you tried closing VSC and running "mvn clean install" and "mvn install" from command line? – rLevv Dec 14 '18 at 01:47
  • I haven't used VSC, but I do use a ton of VS, and have worked a fair bit with Eclipse (unfortunately). Java packages are done via a somewhat obtuse folder structure, but VS might not treat them the same way. Sounds like it can't find your packages. – Scuba Steve Dec 14 '18 at 02:16
  • @rLevv Found out, I didn't even create a maven-project but an eclipse-project from within the IDE, so there is no POM-file yet. Thank you for trying to help. – Florian Brinkmeyer Dec 14 '18 at 02:22
  • @ Scuba Steve Yes, not a fan of eclipse either. – Florian Brinkmeyer Dec 14 '18 at 02:23
  • As you note, the .project file is specific to Eclipse, so I assume will not work with VS Code. – Woodchuck Dec 14 '18 at 03:10
  • VS Code doesn't seem to include generation of Java projects via a template the way some IDEs do. The VS Code page you link to does include a link to a "Maven for Java" extension, though, which may be the way to go. Maven is extremely useful, will greatly simplify your workflow and is a common standard. On the other hand, the project you link to does not use it. Maybe start by following the steps closely (i.e., use Eclipse) to get it working first before moving it to VS Code. – Woodchuck Dec 14 '18 at 03:32

0 Answers0