This week's book giveaway is in the Artificial Intelligence and Machine Learning forum.
We're giving away four copies of Zero to AI - A non-technical, hype-free guide to prospering in the AI era and have Nicolò Valigi and Gianluca Mauro on-line!
See this thread for details.
Win a copy of Zero to AI - A non-technical, hype-free guide to prospering in the AI era this week in the Artificial Intelligence and Machine Learning 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

ClassNotFoundException

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,   I am working on a JSSE tutortial from Oracle.  See the link below.

https://docs.oracle.com/javase/10/security/sample-code-illustrating-secure-socket-connection-client-and-server.htm#JSSEC-GUID-3561ED02-174C-4E65-8BB1-5995E9B7282C

Using the sample code for ClassFileServer I have created a project in netbeans 11.  It cleans and builds OK.
Please see the attached files ClassFileserver.java, and ClassServer.java

When the jar file is executed from the command prompt I get this error:

C:\dist>java -jar ClassFileServer.jar 2001 C:\
Error: Could not find or load main class classfileserver.DateServer
Caused by: java.lang.ClassNotFoundException: classfileserver.DateServer

Note:  I also executed this with the optional arguments, TLS and TLS true.  Same result.

Not sure how to fix this, the text "DateServer" does not appear in either of the java files.

Any help would be appreciated.

Roy
 
Marshal
Posts: 25927
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You didn't post a stack trace, so it looks like that class name is the one that the jar's manifest says is the main class. Did you build that jar or did it come from somewhere else? I had a brief look and I don't see any mention of jar files in the tutorials you linked to.
 
R Nordstrom
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,    I made the jar myself when I created a netbeans project with the 2 given files in the example code.  So I will go back to the tutorial and try executing it exactly as they stated.
 
R Nordstrom
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried executing ClassFileServer.java exactly as the tutorial stated.  It still throws an error.  I think that instead of trying to troubleshoot Oracle's code, I should just find another tutorial on JSSE.  Could you make a recommendation on one that starts with only TCP/IP ( and does not use HTTP ) ?
Thanks   Roy
 
Saloon Keeper
Posts: 12402
269
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The tutorial can hardly be blamed for a JAR that was not built correctly.

Can you zip and share your project somewhere?
 
R Nordstrom
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

here is the zip file for my netbeans project ( ClassFileServer.zip )

https://easyupload.io/gayd2w
 
Paul Clapham
Marshal
Posts: 25927
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

R Nordstrom wrote:I tried executing ClassFileServer.java exactly as the tutorial stated.  It still throws an error.



Should we assume you got the identical error message? If not, it would help greatly if we knew what it said.
 
R Nordstrom
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Paul,  Here is the result from the command window.

C:\dist>java ClassFileServer 2001 C:\
Error: Could not find or load main class ClassFileServer
Caused by: java.lang.ClassNotFoundException: ClassFileServer

I appreciate your time and effort, however, I found another tutorial on JSSE that is going more smoothly.

So I would like to close this issue.

Best Regards

Roy  
 
Paul Clapham
Marshal
Posts: 25927
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've marked the thread as "resolved". Good luck with your project!
reply
    Bookmark Topic Watch Topic
  • New Topic