This week's giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Secure Financial Transactions with Ansible, Terraform, and OpenSCAP and have Lucian Maly on-line!
See this thread for details.
Win a copy of Secure Financial Transactions with Ansible, Terraform, and OpenSCAP this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

Class path on Ubuntu 18.04

 
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have written a simple program on NetBeans in Ununtu 18.04:



The version details of Netbeans are:

Product Version: Apache NetBeans IDE 10.0 (Build 20190203-debian-10.0)
Java: 11.0.10; OpenJDK 64-Bit Server VM 11.0.10+9-Ubuntu-0ubuntu1.18.04
Runtime: OpenJDK Runtime Environment 11.0.10+9-Ubuntu-0ubuntu1.18.04
System: Linux version 4.15.0-135-generic running on amd64; UTF-8; en_US (nb)
User directory: /home/zulfi/.netbeans/10.0
Cache directory: /home/zulfi/.cache/netbeans/10.0



I am getting classpath problem,

"Cant access java.lang
Unable to find package java.lang in classath

I dont know how to set classpath on Ubuntu:



I have attached the image:


Somebody please guide me.

Zulfi.



class-path-problem-on-ubuntu.png
[Thumbnail for class-path-problem-on-ubuntu.png]
 
Marshal
Posts: 72487
315
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is 18.04 still a current version? Yes, it is.

You shouldn't set a system CLASSPATH in the first place. Please show us where you installed Java®, and the PATH you are using. Try this instruction:

[campbell@localhost ~]$ echo $PATH
/usr/java/jdk-15/bin:/usr/java/jdk-15/bin:/home/campbell/.local/bin:/home/campbell/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin

Which is the first directory in your PATH with Java® in? Please show us its contents with ls.
 
Zulfi Khan
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I got following as a result of echo:

$ echo $PATH
/home/zulfi/.nvm/versions/node/v10.23.3/bin:/usr/local/cuda-10.1/bin:/home/zulfi/.local/bin:/opt/QtSDK/Desktop/Qt/473/gcc/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/zulfi/Downloads/omnetpp-5.5.1/bin


Sorry I can't find anything related to java, but when I did:
$ whereis java
java: /usr/bin/java /usr/share/java /usr/share/man/man1/java.1.gz


:/usr/bin$ ls j*
jaotc      javac    jcat      jdeprscan  jhat       jimage  jls   jpeg_extract  jrunscript  json_pp  junit
jar        javadoc  jcmd      jdeps      jhindexer  jinfo   jmap  jpegtopnm     js          jstack
jarsigner  javah    jconsole  jexec      jhsdb      jjs     jmod  jpgicc        jsadebugd   jstat
java       javap    jdb       jfr        jhsearch   jlink   join  jps           jshell      jstatd

Somebody please guide me how to solve the classpath problem in NetBeans?

Zulfi.
 
Campbell Ritchie
Marshal
Posts: 72487
315
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I suspect you are using whichever java is in /usr/bin; confirm that with which java, java -version, and javac -version. It is after all the only place you found with whereis which is also in your PATH.
Then please verify that it is the version of Java® that you actually want. Add the paths to the other two locations to the -version requests and verify their versions.
When you have done that, try exporting a JAVA_HOME variable comprising the desired PATH minus bin.
I still don't think you should set a CLASSPATH.
 
Saloon Keeper
Posts: 23449
159
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The CLASSPATH of the shell that you launched NetBeans into is probably not used at all by NetBeans. Furthermore, unless I'm mistaken, the CLASSPATH that the JVM that runs NetBeans is probably not the CLASSPATH used by projects inside NetBeans.

This is certainly true in the case of the Eclipse IDE, and I'm pretty sure that NetBeans is designed similarly.

So to get the right CLASSPATH for running/debugging a project in NetBeans you need to look at the project properties, and if there's an independent run/debug profile being used (like in Eclipse), you will need to look there, since that's where the classpath for execution of that particular project is defined.
 
Zulfi Khan
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Campbell Ritchie: As you said, I did the following:


openjdk version "11.0.10" 2021-01-19
OpenJDK Runtime Environment (build 11.0.10+9-Ubuntu-0ubuntu1.18.04)
OpenJDK 64-Bit Server VM (build 11.0.10+9-Ubuntu-0ubuntu1.18.04, mixed mode, sharing)

javac 11.0.10

Now I found the location where java is stored: i.e. /usr/lib/jvm
It contains:

default-java               java-11-openjdk-amd64     java-8-openjdk-amd64
java-1.11.0-openjdk-amd64  java-1.8.0-openjdk-amd64  openjdk-11

Now the NetBeans product version says:
Java: 11.0.10; OpenJDK 64-Bit Server VM 11.0.10+9-Ubuntu-0ubuntu1.18.04
I checked openjdk-11 folder:

src.zip
zulfi@lc2530hz:/usr/lib/jvm/openjdk-11$

Then I checked /usr/lib/jvm/java-11-openjdk-amd64 folder:

bin  conf  docs  include  jmods  legal  lib  man  release

So I decided to use /usr/lib/jvm/java-11-openjdk-amd64 as the path for JAVA_HOME

/usr/bin/java




But still I am getting the same error.





Tim Holloway: Thanks. This is not a built in project. I am running Netbeans for the first time on ubuntu 18.04 so I am getting java.lang problem. Netbeans is not able to recognize the "String" class.

Zulfi.
 
Tim Holloway
Saloon Keeper
Posts: 23449
159
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Zulfi Khan wrote:
This is not a built in project. I am running Netbeans for the first time on ubuntu 18.04 so I am getting java.lang problem. Netbeans is not able to recognize the "String" class.



I don't know what the difference between a "built in" project and a non-"built in" project is supposed to be, but unless NetBeans is a lot different than I remember, every bit of user code visible to NetBeans must be in a NetBeans project.

And the project needs to have a JDK associated with it.

Normally when you install an IDE, it looks to see what JDKs and JVMs it can locate that are already in your system and will register one or more of them for use to compile and run NetBeans projects. If you installed NetBeans before installing a JVM, it may not have been able to do so, in which case I'd expect to see an error like what you are getting.

The other thing that can result in that sort of error is if you are not pointing to the root directory of the JDK/JRE that you are trying to use. DO NOT point to the "bin" directory or one of the other sub-directories of the JDK that you downloaded and unzipped. For example, if I downloaded and unzipped the Oracle JDK jdk1.8.0_66, I would unzip it (per Red Hat convention) into the /usr/java/ directory and the JDK location to plug into the IDE would be /usr/java/jdk1.8.0_66.

In the case of OpenJDK, I cannot be so definite, because although OpenJDK is now pre-installed with Fedora Linux, I do all my professional work with the downloaded Oracle products (at least up until now). However, you will probably find that the openJDK equivalent for the /usr/java directory on your machine is /usr/lib/jvm, so a generic path might be /usr/lib/jvm/java-11-openjdk. Because of the "alternatives" feature of Linux, this may lead down one or more aliases (softlinks).
 
Zulfi Khan
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Tim Holloway,
I am still getting the same problem. I did the following:
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk
zulfi@lc2530hz:~$ echo $JAVA_HOME
/usr/lib/jvm/java-11-openjdk


But still I can't run.

I found the following link:
https://askubuntu.com/questions/1196172/netbeans-doesnt-work-in-18-04

It says to install Netbeans 11 classics, I installed it but it is executing Netbeans 10. I have to delete Netbeans 10 from my Ubuntu 18.04 machine.

Somebody please guide me.

Zulfi.
 
Campbell Ritchie
Marshal
Posts: 72487
315
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How did you install NetBeans?
 
Tim Holloway
Saloon Keeper
Posts: 23449
159
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As I said before, I'm pretty sure that NetBeans doesn't get its classpath from the OS environment variables - and that includes JAVA_HOME. You almost certainly have to set the project JDK path using the NetBeans GUI itself.

I could tell you exactly how to do that in Eclipse, but I don't have NetBeans.
 
Zulfi Khan
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Campbell Ritchie-I installed the netbeans 10.0 long time ago but I installed Netbeans 11.0 only two days ago using the snap package:
sudo snap install netbeans --classic

But it won't work until I delete the version 10.0.

I tried to delete version 10.0 but it also requires lot of head scratching so I can't succeed. However, I have found a mailing list for Netbeans but right now I just find that the people are sending questions to Netbeans but no answers. Anyway I would send my question there. If you have any solution please reply.

God blesses you.

Zulfi.
 
Zulfi Khan
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Thank God that my netbeans problem has been solved. Mailing list turned out to be useful:  users@netbeans.apache.org

First they asked me to run the remove command:
sudo apt remove netbeans

I ran it using again using some switch, the previous command showed me and then I typed "netbeans" just for the sake of curiosity and and version 12.2 started downloading. Then I used the following link for executing the program:

https://netbeans.apache.org/kb/docs/java/quickstart.html

God blesses you.

Zulfi.
 
Tongue wrestling. It's not what you think. And here, take this tiny ad. You'll need it.
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic