|
When posting your question please:- Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
- Keep the subject line brief, but descriptive. eg "File Serialization problem"
- Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
- Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
- Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
- If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode HTML tags when pasting" checkbox before pasting anything inside the PRE block, and make sure "Ignore HTML tags in this message" check box is unchecked.
- Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
- Please do not post links to your question in one forum from another, unrelated forum (such as the lounge). It will be deleted.
- Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
- If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
- No advertising or soliciting.
- We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
When answering a question please:
- Read the question carefully
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
- If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
- If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid.
cheers,
Chris Maunder
The Code Project Co-fou
|
|
|
|
|
Is there a way to make the difference between the server being offline, or it being busy with accepting another connection at the exact same time and not being able to accept another one, so that the client knows it wasn't a problem that the server wasn't online to try again to reach it?
|
|
|
|
|
|
Aren't those C++ errors? I was asking for Java socket.
|
|
|
|
|
Yes, but they are based on actual sockets which are the same for all languages. I could not find a definitive list for Java, you should check the Java documentation.
|
|
|
|
|
|
I tried to use that, but that exception is thrown if the server is offline but also when it didn't responded to .connect(...) in time.
|
|
|
|
|
Did the exceptions include any message text to explain what was the underlying cause? When I run my Java client against an offline server I get:
Exception in thread "main" java.net.ConnectException: Connection refused: connect
There may be some more useful information at Java Network Programming FAQ[^].
|
|
|
|
|
|
In my app I'm using JNI, and because of that I have to add into User/System Path the location to jvm.dll from JRE\bin\server . To add a variable in User Path it doesn't require administrator rights, so I'm taking this approach. To add it I'm using REG ADD from CMD with the following functions. The problem that I have is that after I'm adding the variable into Path, the software still doesn't see it and returns the error "jvm.dll not found", but if I restart the computer, then it runs fine and sees the variable. Also after I'm adding it, if I manually go into User Path and double click to edit the variable, and simply press enter without changing anything, then it doesn't require the restart. Does it have something to do with the code/way I'm adding the variable? What should I do to get past this and to get it working without the user/client having to restart the computer before it is working?
Function to run CMD:
std::string executeCMD(const char* cmd) {
std::string result;
std::array<char, 128> buffer;
std::unique_ptr<FILE, decltype(&_pclose)> pipe(_popen(cmd, "r"), _pclose);
if (!pipe) {
return "ErrorCMD";
}
while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr) {
result += buffer.data();
}
return result;
}
Use of the function:
resultCMD.insert(0, "reg add \"HKEY_CURRENT_USER\\Environment\" /v PATH /t REG_EXPAND_SZ /d \"");
resultCMD.append("\" /f");
executeCMD(resultCMD.c_str());
resultCMD is a std::string which contains the values that were in Path and also the value that I'm adding under the following format with "C:\Program Files\Eclipse Adoptium\jre-18.0.1.10-hotspot\bin\server" being added after I use the function from above:
C:\Program Files\Eclipse Adoptium\jre-18.0.1.10-hotspot\bin\server;D:\Program Files (x86)\VMware\VMware Player\bin\;D:\Program Files\Python\Python310\Scripts\;D:\Program Files\Python\Python310\;C:\Windows\system32;C:\Windows; ...and the rest of the variables, this was as an example, after each variable they have a ;
|
|
|
|
|
I ended up switching to use RegOpenKeyExA, RegQueryValueExA, RegCreateKeyEx, RegSetValueExA to get and add the values into Path, that way I can use SendNotifyMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM)TEXT("Environment")); to get past the need for a system restart/logout.
|
|
|
|
|
If I'm planning to distribute some software that uses Java, can I simply add in it's folder structure jre-8u333-windows-x64.exe (or other versions, this was the latest) for those that don't have it and prompt them to install it? Or beside that I need to add a file with Oracle license and have the user tick a box that they agree? Or do I have to buy something from Oracle?
The software will be free but it contains microtransactions for profit.
|
|
|
|
|
If you're bundling Oracle software, then you go with what the Oracle license says.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
|
I'm using jdk1.8.0_333 / jre1.8.0_333. Do you know if this is a problem or not? Or I need to try to switch to a new version to be free? I'm not really going to make money from my first release, so I would like to try to keep it free.
Also I've seen that there is another source for Java: OpenJDK[^] / OpenJDK JDK 18.0.1.1 GA Release[^]. Is this one free, while the one from Oracle you need a subscription but contains some more advanced features/libraries?
|
|
|
|
|
For the definitive answer that's going to deal with money, the ONLY people you should be asking this question of is Oracle Support.
|
|
|
|
|
Because this is a issue that can lead to financial/law problems I took a look at JDK's and I found Adoptium[^]. Do you know if this is free for commercial use? I see that they have JDK and JRE. I will try to contact them as well, but for sure it will take quite a long time before they respond.
|
|
|
|
|
I don't do Java.
The only reason I know about the licensing is because of the licensing requirements at work.
|
|
|
|
|
public class student{
private int ID;
private String Name;
Student class constructor
student(int id, String name){
this.ID = id;
this.Name = name;}
public int getid(){
return this.ID;}
public String Getname(){
return this.Name;}
public void SETid(int i){
this.ID = i;}
public void sETNAme(String n){
this.Name=n;}
method to display data
public void display() {
System.out.println("Student id is: " + id + " "
+ "and Student name is: "
+ Name;);
System.out.println();
}}
|
|
|
|
|
No.
Even if you'd asked nicely, you haven't bothered to tell us what "the error" is.
Dumping your code without explanation and demanding that someone "solve the error" is a great way to alienate people, and ensure nobody wants to help you.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Let's start by formatting the code and adding ;line numbers so it is actually readable. You can now clearly see that at the very least you have invalid lines at lines numbers 5 and 22. I assume these are supposed to be comment lines so require a "//" at the beginning. You also have mixed capitalisation on your setters and getters.
So start by fixing those and see what happens.
1 public class student{
2 private int ID;
3 private String Name;
4
5 Student class constructor
6 student(int id, String name){
7 this.ID = id;
8 this.Name = name;
9 }
10 public int getid(){
11 return this.ID;
12 }
13 public String Getname(){
14 return this.Name;
15 }
16 public void SETid(int i){
17 this.ID = i;
18 }
19 public void sETNAme(String n){
20 this.Name=n;
21 }
22 method to display data
23 public void display() {
24 System.out.println("Student id is: " + id + " "
25 + "and Student name is: "
26 + Name;
27 );
28 System.out.println();
29 }
30 }
|
|
|
|
|
You forget to add // on commenting lines that is in line number 5 and 22
public class student{
private int ID;
private String Name;
student(int id, String name){
this.ID = id;
this.Name = name;
}
public int getid(){
return this.ID;
}
public String Getname(){
return this.Name;
}
public void SETid(int i){
this.ID = i;
}
public void sETNAme(String n){
this.Name=n;
}
public void display() {
System.out.println("Student id is: " + id + " "
+ "and Student name is: "
+ Name;
);
System.out.println();
}
}
|
|
|
|
|
See my answer of 9th June above.
|
|
|
|
|
He already did, when he cut'n'pasted it
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
Hello. I'm new to Java -- I want to learn, and am going through HFJ. I know it's an old book, but there are no later editions, so I may be behind the times.
I'm not a professional programmer, but I'm on a few programming forums, and I can't seem to get an answer to a question I have regarding the Runnable interface. I'm in chap 15 of the book re: threading, and I came across this statement in regards to starting a new thread:
public class MyRunnable implements Runnable
Runnable threadJob = new MyRunnable ()
What I don't understand is how can you make a new object with an interface, but use the class MyRunnable. Shouldn't it be MyRunnable thread = new MyRunnable ()?
I'm just confused. Runnable isn't a class, so what's going on?
|
|
|
|