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

Java project not found #1430

Closed
jav-ed opened this issue Jan 24, 2024 · 3 comments
Closed

Java project not found #1430

jav-ed opened this issue Jan 24, 2024 · 3 comments

Comments

@jav-ed
Copy link

jav-ed commented Jan 24, 2024

It is a gradle project and gradle is able to execute (run, debug, build,..) it. IntelliJ IDEA is also able to get the code running. However, as soon as I come over to VSCode, it says

ConfigError:The porject 'First_Proj' is not a valid project

0

The link : https://github.com/Microsoft/vscode-java-debug/blob/main/Troubleshooting.md#failed-to-resolve-classpath did not help to resolve the issue

Environment
➜  bin lsb_release -a
LSB Version:	core-2.0-noarch:core-3.2-noarch:core-4.0-noarch:core-2.0-x86_64:core-3.2-x86_64:core-4.0-x86_64:desktop-4.0.fake-amd64:desktop-4.0.fake-noarch:graphics-2.0-amd64:graphics-2.0-noarch:graphics-3.2-amd64:graphics-3.2-noarch:graphics-4.0.fake-amd64:graphics-4.0.fake-noarch
Distributor ID:	openSUSE
Description:	openSUSE Leap 15.5
Release:	15.5
Codename:	n/a
➜  bin java -version
openjdk version "17.0.3" 2022-04-19
OpenJDK Runtime Environment Temurin-17.0.3+7 (build 17.0.3+7)
OpenJDK 64-Bit Server VM Temurin-17.0.3+7 (build 17.0.3+7, mixed mode, sharing)
  • VSCode
    Version: 1.85.2
    Commit: 8b3775030ed1a69b13e4f4c628c612102e30a681
    Date: 2024-01-18T06:40:19.222Z
    Electron: 25.9.7
    ElectronBuildId: 26354273
    Chromium: 114.0.5735.289
    Node.js: 18.15.0
    V8: 11.4.183.29-electron.0
    OS: Linux x64 5.14.21-150500.55.39-default

  • Java extension version: Language Support for Java(TM) by Red Hat
    v1.26.0

  • Java Debugger extension version: v0.55.0

Steps To Reproduce

Unfortunately, I am working on a project, that I cannot share. However, maybe you have some ideas, you want me to check and I inshallah can give you my outcome

Current Result

Project is not detected as valid project --> code does not run at all using the vscode debugger

Expected Result

The code should be executable

Additional Informations

content of: settings.gradle:
rootProject.name = 'First_Proj'

content of : launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "java",
            "name": "Launch Current File",
            "request": "launch",
            "mainClass": "${file}"
        },
        
        {
            "type": "java",
            "name": "Main",
            "request": "launch",
            "mainClass": "Main",
            "projectName": "First_Proj"
        }
    ]
}
@testforstephen
Copy link
Contributor

What project name do you see in Java Projects view?

image

@jav-ed
Copy link
Author

jav-ed commented Feb 6, 2024

Screenshot_20240206_113227

now adapting the project name, the project is found and the initial issue is resolved (great):

        {
            "type": "java",
            "name": "Main",
            "request": "launch",
            "mainClass": "Main",
            "projectName": "1_Tank_Modeler"
        }

While the project is found and it can be run with the debugger, there is still another issue that does not occur with IntelliJ:

Working Directory = /masked/1_Tank_Modeler
Exception in thread "main" java.lang.NullPointerException
        at java.base/java.io.Reader.<init>(Reader.java:168)
        at java.base/java.io.InputStreamReader.<init>(InputStreamReader.java:76)
        at tubestruct.geometrylibrary.GeoDatReader.inputGeoDat(GeoDatReader.java:41)
        at tubestruct.geometrylibrary.GeoDatReader.<init>(GeoDatReader.java:21)
        at tubestruct.Tubestruct.<init>(Tubestruct.java:132)
        at Main.main(Main.java:58)

@jav-ed
Copy link
Author

jav-ed commented Feb 6, 2024

So, the problem is that a file is not found. The following code shows where I try to open the file.

    private double[][] inputGeoDat (String geoDatName) {
        double[][] geoDat = null;
        
        String fileName   = "data/" + geoDatName + ".dat";
        // String fileName   = "./tubestruct/geometrylibrary/data/fx73k170_WKW80_RadDat.dat";
        
        System.out.println("Working Directory = " + System.getProperty("user.dir"));
                
        ArrayList<double[]> data = new ArrayList<>();

        int nData = 0;

        BufferedReader reader = new BufferedReader(
            new InputStreamReader(this.getClass().getResourceAsStream(fileName)));

The following image shows that the file I am trying to access is found in the "JAVA PROJECTS" view

java

@jav-ed jav-ed closed this as completed Feb 7, 2024
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