Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Class Not Found Question  RSS feed

 
Michael Scott
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a Java agent that runs on the web. While running, if it comes upon a line of code that references a class that does not exist, the agent simply hangs. I'll then have to do a http restart on the server. For example, the following line will not execute because the class cannot be found. (I'm still looking into why the class cannot be found.)

variableName = new className();

Isn't there a means of simply checking the availability of the class in the code without causing the agent to hang? I thought that some try-catch logic could do this, but I haven't had success in coming up with this.

Thanks.
 
bhavesh bhanushali
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a Java agent that runs on the web. While running, if it comes upon a line of code that references a class that does not exist, the agent simply hangs. I'll then have to do a http restart on the server. For example, the following line will not execute because the class cannot be found. (I'm still looking into why the class cannot be found.)

variableName = new className();

Isn't there a means of simply checking the availability of the class in the code without causing the agent to hang? I thought that some try-catch logic could do this, but I haven't had success in coming up with this.

Thanks

Yup u can do that

try {
// your class related code here
}
catch ( Class ClassNotFoundException exp ) (
// catch the exception and move on
}

I guess this should solve the problem
 
bhavesh bhanushali
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try {

}

catch ( ClassNotFoundException exp ) {

}

I am sorry the word class was repeated in the earlier code
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!