Before I get to the problem, here is what I am trying to do. So I have an assignment where you are supposed to take some sort of variable based code, interpret it, then spit out java code that connects to a database based on the latter. So basically it is java code that reads a file, and outputs a java file based on what is in the file. The output java code has to be output into a different directory (THIS IS THE PROBLEM). Also he gave us files that help us login and help with authentication. Here is the problem when I am in the directory with the output java code, and I run it, it connects to the database no problem, but when I am in any other directory, the code runs fine, but it doesn't want to connect to the database. Here are the arguments I use to run the code.
java -cp /usr/share/java/postgresql-jdbc4-
9.1.jar:/home/undergrad/3/USERNAME/testDoc/bin/a1
-Djava.security.krb5.conf=krb5.conf
-Djava.security.auth.login.config=jaas.conf a1
Since this is an assignment I can't put all my code on here, but here is the code to add something to a database. Keep in mind that this is generated code, and that that is why it looks so ugly, but the assignment is due tonight, so I can't really change that.
The stacktrace says that
the GSS authentication failed, it ended in a PSQLException. So there was an error while connecting. Yea it said it couldn't find the authentication files.
Related
I am currently working on a university project involving police patrol management. It is necessary to implement different security elements in order to keep the data protected. I have therefore designed a beginning of a Client Server application.
All works well when running on IntelliJ but things get complicated once in command line. The compilation works but the execution is impossible because of a java.lang.NoClassDefFoundError.
Here is my Project Structure :
enter image description here
Here is the error after trying to run only the Server side of the project :
enter image description here
Is this error due to the fact that I am using files with secret keys and a certificate ? Or is it just my structure that is causing the problem ?
Can you help me ?
I think every thing is ok except one thing..pay attention at ServerSide/Server
look at the second image you have sent ..
I had same problem . Look at this answer NoClassDefFoundError: wrong name
You need to run it from the package root on. Go one folder up so that you're in the folder which in turn contains the "ServerSide" folder representing the package and then execute " java ServerSide .Server"
I wrote a java program, which manipulates Word documents (docx) with Apache POI. It runs fine within Eclipse, and it runs fine as a runnable JAR on my computer (Windows 10).
I copied that JAR to another computer, and it is starting up normally. The GUI behaves like expected.
The problem is the Word document I write out (docx).
I am performing two types of changes. The first one is the addition of new paragraphs or concatenation of content to the runs. If I stay with this, the document gets written into the file system correctly. The second type is the simple replacement of content within the runs (changes of words and some grammatical changes). I would see that part as the "simpler" one, but if I stay with this or if I combine both change types, no document is written out at all. It does look like there is a bug, but there isn't one because it worked fine on my system.
I wrote myself a function to write out an error log (txt) to get information about that issue. This one worked on both systems. But the log didn't get any information, why the document was not written out.
I suppose there are some Windows security settings which interfer with my program or something like that. The computer that does not like to run my program has Win 7 installed on it, and there are some security domain settings, which affect all other computers in the local network.
Does anyone experienced something similar yet? Any suggestions what to check? Suggestions how to find out if an error happened are appreciated as well.
OK, the problem got solved by simply updating the Java version. I saw that update icon in the system tray, which didn't open update the update dialog. So I wanted to update the Java-version at least.
When I wanted to de-install the current Java version first, I noticed that the Win7-machine hadn't a Java-update for three years now. It was just installed in 2014. As soon as the recent version was installed, everything worked like expected again.
The strange behavior that some parts of my program worked and some not, confused me. I hoped that the Java update would fix this, but I doubted that. I didn't knew that old versions make programs run unpredictably.
[I know this question has been asked here and here, but I don't quite understand the answers, and I didn't want to ask questions on old threads.]
Problem:
I have a project that I created in NetBeans (7.01), and I created a database to go with it using Java DB. I would like to have a .exe file that I can run on any computer, so that when someone clicks it, the program runs like it should (establish the connection with the db, run the rest of the Java code).
What I know:
After a little reading, I see that if I didn't have the DB, the executable that I am looking for would really just be the .jar file. I also found that I needed to create an embedded db which in part means that I need to change the URL from jdbc:derby://localhost... to something different (but I'm not sure what something should be. Just a path to the source code files perhaps with the db information?).
Question:
I have a bunch of pieces (not sure if they're all right), but I am not sure how to put them all together. Could someone let me know how to create an embedded DB and send that, and the rest of the program, to an .exe?
Thanks in advance!
I am in a very very upset situation. My program worked 100% fine when it is in netbeans, but when I build it it has some issues. That is, in my program, there is an one interface and 10 implementation classes. Program calls correct correct implementation class based on how the user save the file (eg: if user save it as game.yellow, it will call "YellowImpl.java", if saved as game.red, then "RedImpl.java" likewise).
But when it is built, it is calling everything fine, instead YellowImpl!! Which means, if the user saves it as game.red, it will call "RedImpl" correctly and same to all other implementations instead YellowImpl. When the user save the file as game.yellow, the program do nothing!!! But this is not happening when it is inside the netbeans! I tried clean and build too, still not good! What is causing this ? Please help!
However, I am unable to provide the code, because it has lot of codings
PS: I am using some libs too
It's difficult to understand exactly what issue you are having with your explaination and no code. However I assume you are having issue with implementation naming conventions.
Perhaps the below link can help.
Java Interfaces/Implementation naming convention
I am agree with #Rhys: it is hard to understand what happens in your application. Just let me give you an advice: do not think (even for 1 second) that there is a bug in java compiler, JVM etc. It is definitely your bug.
How to find it? I suggest you to use remote debugging.
Run your application outside IDE (NetBeans in your case) with enabled remote debugger, connect to it with net beans and debug your application. I believe you will fined the problem within minutes.
How to enable remote debugging? Add the following long string to your java execution command line:
-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
If something happens in very beginning of your program execution use suspend=y.
Now connect to this application from NetBeans. It is simple, just configure it to port 8000 according to the configuration of your application.
That's it. Good luck.
Thanks a lot for the replies guys. However, I managed to find the issue. That was a simple, capital case!! I have a package called "kolor" and all the implementations are inside that. In my "YelloImpl" class, I have mentioned the package as "Kolor" (Note that "K" is capital). It was fine in netbeans, but outside it wasn't. After clearing this out, everything went fine. Thanks all for the replies again.
I created a small application that, when run, creates or updates some tables in a database by extracting data from some PDF files. Everything works fine in this desktop application, but the next step for me would be to make it possible for an administrator on a website to upload a PDF file and my Java program would then run and update the tables accordingly.
The problem is I have no idea where to start with this (the site isn't done yet, but I'm running some tests and it is going to be coded in PHP). I'd like to know what kind of technologies I need to let the server run the program and update everything as it would in the offline version. Sometimes it takes a while to update everything, so ideally, the user uploading the PDF could continue browsing other pages while the server does its job. (I'll probably implement something that when the server is done processing the file, it says if the program ended successfully or not in a log file)
Can someone tell me what terms to search for on Google or give me some pointers? I haven't chosen where my website is going to be hosted either, so if someone could tell me what to look for to know if they support running applications like this, I'd really appreciate it as well!
This could also apply to other programming languages as I know a bit of Python and C++ as well, so in the future I might have some applications in those languages I'll want to use on the web.
If I'm not approaching this the right way, I'm open to other suggestions, but the best solution would be to keep my Java program intact as I know it works exactly like I want it to and I'd rather not have to start it all over again.
If your host is *NIX based you can use crontab (Automatic Task Scheduler) to run your program at set intervals. Make it check if a "new" PDF exists, and run the program if there is. There may be a way to use Windows Task Scheduler type programs to do it on Windows. This is probably the easiest way.
Alternately you can use You can use shell_exec() in your php to execute a command on your *NIX system directly to run your java program.